repo_id stringclasses 875
values | size int64 974 38.9k | file_path stringlengths 10 308 | content stringlengths 974 38.9k |
|---|---|---|---|
googleapis/google-cloud-java | 36,281 | java-deploy/proto-google-cloud-deploy-v1/src/main/java/com/google/cloud/deploy/v1/Standard.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/deploy/v1/cloud_deploy.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.deploy.v1;
/**
*
*
* <pre>
* Standard represents the standard deployment strategy.
* </pre>
*
* Protobuf type {@code google.cloud.deploy.v1.Standard}
*/
public final class Standard extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.deploy.v1.Standard)
StandardOrBuilder {
private static final long serialVersionUID = 0L;
// Use Standard.newBuilder() to construct.
private Standard(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private Standard() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new Standard();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.deploy.v1.CloudDeployProto
.internal_static_google_cloud_deploy_v1_Standard_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.deploy.v1.CloudDeployProto
.internal_static_google_cloud_deploy_v1_Standard_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.deploy.v1.Standard.class,
com.google.cloud.deploy.v1.Standard.Builder.class);
}
private int bitField0_;
public static final int VERIFY_FIELD_NUMBER = 1;
private boolean verify_ = false;
/**
*
*
* <pre>
* Optional. Whether to verify a deployment via `skaffold verify`.
* </pre>
*
* <code>bool verify = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The verify.
*/
@java.lang.Override
public boolean getVerify() {
return verify_;
}
public static final int PREDEPLOY_FIELD_NUMBER = 2;
private com.google.cloud.deploy.v1.Predeploy predeploy_;
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return Whether the predeploy field is set.
*/
@java.lang.Override
public boolean hasPredeploy() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return The predeploy.
*/
@java.lang.Override
public com.google.cloud.deploy.v1.Predeploy getPredeploy() {
return predeploy_ == null
? com.google.cloud.deploy.v1.Predeploy.getDefaultInstance()
: predeploy_;
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
@java.lang.Override
public com.google.cloud.deploy.v1.PredeployOrBuilder getPredeployOrBuilder() {
return predeploy_ == null
? com.google.cloud.deploy.v1.Predeploy.getDefaultInstance()
: predeploy_;
}
public static final int POSTDEPLOY_FIELD_NUMBER = 3;
private com.google.cloud.deploy.v1.Postdeploy postdeploy_;
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return Whether the postdeploy field is set.
*/
@java.lang.Override
public boolean hasPostdeploy() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return The postdeploy.
*/
@java.lang.Override
public com.google.cloud.deploy.v1.Postdeploy getPostdeploy() {
return postdeploy_ == null
? com.google.cloud.deploy.v1.Postdeploy.getDefaultInstance()
: postdeploy_;
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
@java.lang.Override
public com.google.cloud.deploy.v1.PostdeployOrBuilder getPostdeployOrBuilder() {
return postdeploy_ == null
? com.google.cloud.deploy.v1.Postdeploy.getDefaultInstance()
: postdeploy_;
}
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 (verify_ != false) {
output.writeBool(1, verify_);
}
if (((bitField0_ & 0x00000001) != 0)) {
output.writeMessage(2, getPredeploy());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(3, getPostdeploy());
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (verify_ != false) {
size += com.google.protobuf.CodedOutputStream.computeBoolSize(1, verify_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getPredeploy());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getPostdeploy());
}
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.deploy.v1.Standard)) {
return super.equals(obj);
}
com.google.cloud.deploy.v1.Standard other = (com.google.cloud.deploy.v1.Standard) obj;
if (getVerify() != other.getVerify()) return false;
if (hasPredeploy() != other.hasPredeploy()) return false;
if (hasPredeploy()) {
if (!getPredeploy().equals(other.getPredeploy())) return false;
}
if (hasPostdeploy() != other.hasPostdeploy()) return false;
if (hasPostdeploy()) {
if (!getPostdeploy().equals(other.getPostdeploy())) 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();
hash = (37 * hash) + VERIFY_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getVerify());
if (hasPredeploy()) {
hash = (37 * hash) + PREDEPLOY_FIELD_NUMBER;
hash = (53 * hash) + getPredeploy().hashCode();
}
if (hasPostdeploy()) {
hash = (37 * hash) + POSTDEPLOY_FIELD_NUMBER;
hash = (53 * hash) + getPostdeploy().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.deploy.v1.Standard parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.deploy.v1.Standard 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.deploy.v1.Standard parseFrom(com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.deploy.v1.Standard 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.deploy.v1.Standard parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.deploy.v1.Standard parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.deploy.v1.Standard parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.deploy.v1.Standard 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.deploy.v1.Standard parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.deploy.v1.Standard 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.deploy.v1.Standard parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.deploy.v1.Standard 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.deploy.v1.Standard 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;
}
/**
*
*
* <pre>
* Standard represents the standard deployment strategy.
* </pre>
*
* Protobuf type {@code google.cloud.deploy.v1.Standard}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.deploy.v1.Standard)
com.google.cloud.deploy.v1.StandardOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.deploy.v1.CloudDeployProto
.internal_static_google_cloud_deploy_v1_Standard_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.deploy.v1.CloudDeployProto
.internal_static_google_cloud_deploy_v1_Standard_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.deploy.v1.Standard.class,
com.google.cloud.deploy.v1.Standard.Builder.class);
}
// Construct using com.google.cloud.deploy.v1.Standard.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getPredeployFieldBuilder();
getPostdeployFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
verify_ = false;
predeploy_ = null;
if (predeployBuilder_ != null) {
predeployBuilder_.dispose();
predeployBuilder_ = null;
}
postdeploy_ = null;
if (postdeployBuilder_ != null) {
postdeployBuilder_.dispose();
postdeployBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.deploy.v1.CloudDeployProto
.internal_static_google_cloud_deploy_v1_Standard_descriptor;
}
@java.lang.Override
public com.google.cloud.deploy.v1.Standard getDefaultInstanceForType() {
return com.google.cloud.deploy.v1.Standard.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.deploy.v1.Standard build() {
com.google.cloud.deploy.v1.Standard result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.deploy.v1.Standard buildPartial() {
com.google.cloud.deploy.v1.Standard result = new com.google.cloud.deploy.v1.Standard(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.deploy.v1.Standard result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.verify_ = verify_;
}
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.predeploy_ = predeployBuilder_ == null ? predeploy_ : predeployBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.postdeploy_ = postdeployBuilder_ == null ? postdeploy_ : postdeployBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.deploy.v1.Standard) {
return mergeFrom((com.google.cloud.deploy.v1.Standard) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.deploy.v1.Standard other) {
if (other == com.google.cloud.deploy.v1.Standard.getDefaultInstance()) return this;
if (other.getVerify() != false) {
setVerify(other.getVerify());
}
if (other.hasPredeploy()) {
mergePredeploy(other.getPredeploy());
}
if (other.hasPostdeploy()) {
mergePostdeploy(other.getPostdeploy());
}
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 8:
{
verify_ = input.readBool();
bitField0_ |= 0x00000001;
break;
} // case 8
case 18:
{
input.readMessage(getPredeployFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
case 26:
{
input.readMessage(getPostdeployFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000004;
break;
} // case 26
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 boolean verify_;
/**
*
*
* <pre>
* Optional. Whether to verify a deployment via `skaffold verify`.
* </pre>
*
* <code>bool verify = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The verify.
*/
@java.lang.Override
public boolean getVerify() {
return verify_;
}
/**
*
*
* <pre>
* Optional. Whether to verify a deployment via `skaffold verify`.
* </pre>
*
* <code>bool verify = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The verify to set.
* @return This builder for chaining.
*/
public Builder setVerify(boolean value) {
verify_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Whether to verify a deployment via `skaffold verify`.
* </pre>
*
* <code>bool verify = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearVerify() {
bitField0_ = (bitField0_ & ~0x00000001);
verify_ = false;
onChanged();
return this;
}
private com.google.cloud.deploy.v1.Predeploy predeploy_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.deploy.v1.Predeploy,
com.google.cloud.deploy.v1.Predeploy.Builder,
com.google.cloud.deploy.v1.PredeployOrBuilder>
predeployBuilder_;
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return Whether the predeploy field is set.
*/
public boolean hasPredeploy() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return The predeploy.
*/
public com.google.cloud.deploy.v1.Predeploy getPredeploy() {
if (predeployBuilder_ == null) {
return predeploy_ == null
? com.google.cloud.deploy.v1.Predeploy.getDefaultInstance()
: predeploy_;
} else {
return predeployBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder setPredeploy(com.google.cloud.deploy.v1.Predeploy value) {
if (predeployBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
predeploy_ = value;
} else {
predeployBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder setPredeploy(com.google.cloud.deploy.v1.Predeploy.Builder builderForValue) {
if (predeployBuilder_ == null) {
predeploy_ = builderForValue.build();
} else {
predeployBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder mergePredeploy(com.google.cloud.deploy.v1.Predeploy value) {
if (predeployBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& predeploy_ != null
&& predeploy_ != com.google.cloud.deploy.v1.Predeploy.getDefaultInstance()) {
getPredeployBuilder().mergeFrom(value);
} else {
predeploy_ = value;
}
} else {
predeployBuilder_.mergeFrom(value);
}
if (predeploy_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder clearPredeploy() {
bitField0_ = (bitField0_ & ~0x00000002);
predeploy_ = null;
if (predeployBuilder_ != null) {
predeployBuilder_.dispose();
predeployBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public com.google.cloud.deploy.v1.Predeploy.Builder getPredeployBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getPredeployFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public com.google.cloud.deploy.v1.PredeployOrBuilder getPredeployOrBuilder() {
if (predeployBuilder_ != null) {
return predeployBuilder_.getMessageOrBuilder();
} else {
return predeploy_ == null
? com.google.cloud.deploy.v1.Predeploy.getDefaultInstance()
: predeploy_;
}
}
/**
*
*
* <pre>
* Optional. Configuration for the predeploy job. If this is not configured,
* the predeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Predeploy predeploy = 2 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.deploy.v1.Predeploy,
com.google.cloud.deploy.v1.Predeploy.Builder,
com.google.cloud.deploy.v1.PredeployOrBuilder>
getPredeployFieldBuilder() {
if (predeployBuilder_ == null) {
predeployBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.deploy.v1.Predeploy,
com.google.cloud.deploy.v1.Predeploy.Builder,
com.google.cloud.deploy.v1.PredeployOrBuilder>(
getPredeploy(), getParentForChildren(), isClean());
predeploy_ = null;
}
return predeployBuilder_;
}
private com.google.cloud.deploy.v1.Postdeploy postdeploy_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.deploy.v1.Postdeploy,
com.google.cloud.deploy.v1.Postdeploy.Builder,
com.google.cloud.deploy.v1.PostdeployOrBuilder>
postdeployBuilder_;
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return Whether the postdeploy field is set.
*/
public boolean hasPostdeploy() {
return ((bitField0_ & 0x00000004) != 0);
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return The postdeploy.
*/
public com.google.cloud.deploy.v1.Postdeploy getPostdeploy() {
if (postdeployBuilder_ == null) {
return postdeploy_ == null
? com.google.cloud.deploy.v1.Postdeploy.getDefaultInstance()
: postdeploy_;
} else {
return postdeployBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder setPostdeploy(com.google.cloud.deploy.v1.Postdeploy value) {
if (postdeployBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
postdeploy_ = value;
} else {
postdeployBuilder_.setMessage(value);
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder setPostdeploy(com.google.cloud.deploy.v1.Postdeploy.Builder builderForValue) {
if (postdeployBuilder_ == null) {
postdeploy_ = builderForValue.build();
} else {
postdeployBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder mergePostdeploy(com.google.cloud.deploy.v1.Postdeploy value) {
if (postdeployBuilder_ == null) {
if (((bitField0_ & 0x00000004) != 0)
&& postdeploy_ != null
&& postdeploy_ != com.google.cloud.deploy.v1.Postdeploy.getDefaultInstance()) {
getPostdeployBuilder().mergeFrom(value);
} else {
postdeploy_ = value;
}
} else {
postdeployBuilder_.mergeFrom(value);
}
if (postdeploy_ != null) {
bitField0_ |= 0x00000004;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder clearPostdeploy() {
bitField0_ = (bitField0_ & ~0x00000004);
postdeploy_ = null;
if (postdeployBuilder_ != null) {
postdeployBuilder_.dispose();
postdeployBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public com.google.cloud.deploy.v1.Postdeploy.Builder getPostdeployBuilder() {
bitField0_ |= 0x00000004;
onChanged();
return getPostdeployFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public com.google.cloud.deploy.v1.PostdeployOrBuilder getPostdeployOrBuilder() {
if (postdeployBuilder_ != null) {
return postdeployBuilder_.getMessageOrBuilder();
} else {
return postdeploy_ == null
? com.google.cloud.deploy.v1.Postdeploy.getDefaultInstance()
: postdeploy_;
}
}
/**
*
*
* <pre>
* Optional. Configuration for the postdeploy job. If this is not configured,
* the postdeploy job will not be present.
* </pre>
*
* <code>
* .google.cloud.deploy.v1.Postdeploy postdeploy = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.deploy.v1.Postdeploy,
com.google.cloud.deploy.v1.Postdeploy.Builder,
com.google.cloud.deploy.v1.PostdeployOrBuilder>
getPostdeployFieldBuilder() {
if (postdeployBuilder_ == null) {
postdeployBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.deploy.v1.Postdeploy,
com.google.cloud.deploy.v1.Postdeploy.Builder,
com.google.cloud.deploy.v1.PostdeployOrBuilder>(
getPostdeploy(), getParentForChildren(), isClean());
postdeploy_ = null;
}
return postdeployBuilder_;
}
@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.deploy.v1.Standard)
}
// @@protoc_insertion_point(class_scope:google.cloud.deploy.v1.Standard)
private static final com.google.cloud.deploy.v1.Standard DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.deploy.v1.Standard();
}
public static com.google.cloud.deploy.v1.Standard getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<Standard> PARSER =
new com.google.protobuf.AbstractParser<Standard>() {
@java.lang.Override
public Standard 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<Standard> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<Standard> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.deploy.v1.Standard getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/hadoop | 36,279 | hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/PBImageTextWriter.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hdfs.tools.offlineImageViewer;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.XAttr;
import org.apache.hadoop.fs.permission.PermissionStatus;
import org.apache.hadoop.hdfs.XAttrHelper;
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite;
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode;
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf;
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf.SectionName;
import org.apache.hadoop.hdfs.server.namenode.FSImageUtil;
import org.apache.hadoop.hdfs.server.namenode.FsImageProto;
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.FileSummary;
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection;
import org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode;
import org.apache.hadoop.hdfs.server.namenode.INodeId;
import org.apache.hadoop.hdfs.server.namenode.SerialNumberManager;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.io.WritableUtils;
import org.apache.hadoop.util.LimitInputStream;
import org.apache.hadoop.util.Lists;
import org.apache.hadoop.util.Time;
import org.fusesource.leveldbjni.JniDBFactory;
import org.iq80.leveldb.DB;
import org.iq80.leveldb.Options;
import org.iq80.leveldb.WriteBatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.util.Preconditions;
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.XATTR_ERASURECODING_POLICY;
/**
* This class reads the protobuf-based fsimage and generates text output
* for each inode to {@link PBImageTextWriter#out}. The sub-class can override
* {@link #getEntry(String, INode)} to generate formatted string for each inode.
*
* Since protobuf-based fsimage does not guarantee the order of inodes and
* directories, PBImageTextWriter runs two-phase scans:
*
* <ol>
* <li>The first phase, PBImageTextWriter scans the INode sections to reads the
* filename of each directory. It also scans the INode_Dir sections to loads
* the relationships between a directory and its children. It uses these metadata
* to build FS namespace and stored in {@link MetadataMap}</li>
* <li>The second phase, PBImageTextWriter re-scans the INode sections. For each
* inode, it looks up the path of the parent directory in the {@link MetadataMap},
* and generate output.</li>
* </ol>
*
* Two various of {@link MetadataMap} are provided. {@link InMemoryMetadataDB}
* stores all metadata in memory (O(n) memory) while
* {@link LevelDBMetadataMap} stores metadata in LevelDB on disk (O(1) memory).
* User can choose between them based on the time/space tradeoffs.
*/
abstract class PBImageTextWriter implements Closeable {
private static final Logger LOG =
LoggerFactory.getLogger(PBImageTextWriter.class);
static final String DEFAULT_DELIMITER = "\t";
static final String CRLF = StringUtils.CR + StringUtils.LF;
/**
* This metadata map is used to construct the namespace before generating
* text outputs.
*
* It contains two mapping relationships:
* <p>
* <li>It maps each inode (inode Id) to its parent directory (inode Id).</li>
* <li>It maps each directory from its inode Id.</li>
* </p>
*/
private static interface MetadataMap extends Closeable {
/**
* Associate an inode with its parent directory.
*/
public void putDirChild(long parentId, long childId) throws IOException;
/**
* Associate a directory with its inode Id.
*/
public void putDir(INode dir) throws IOException;
/** Get the full path of the parent directory for the given inode. */
public String getParentPath(long inode) throws IOException;
/** Synchronize metadata to persistent storage, if possible */
public void sync() throws IOException;
/** Returns the name of inode. */
String getName(long id) throws IOException;
/**
* Returns the id of the parent's inode, if mentioned in
* INodeDirectorySection, throws IgnoreSnapshotException otherwise.
*/
long getParentId(long id) throws IOException;
}
/**
* Maintain all the metadata in memory.
*/
private static class InMemoryMetadataDB implements MetadataMap {
/**
* Represent a directory in memory.
*/
private static class Dir {
private final long inode;
private Dir parent = null;
private String name;
private String path = null; // cached full path of the directory.
Dir(long inode, String name) {
this.inode = inode;
this.name = name;
}
private void setParent(Dir parent) {
Preconditions.checkState(this.parent == null);
this.parent = parent;
}
/**
* Returns the full path of this directory.
*/
String getPath() throws IgnoreSnapshotException {
if (this.parent == null) {
if (this.inode == INodeId.ROOT_INODE_ID) {
return "/";
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Not root inode with id {} having no parent.", inode);
}
throw PBImageTextWriter.createIgnoredSnapshotException(inode);
}
}
if (this.path == null) {
this.path = new Path(parent.getPath(), name.isEmpty() ? "/" : name).
toString();
}
return this.path;
}
String getName() throws IgnoreSnapshotException {
return name;
}
long getId() {
return inode;
}
@Override
public boolean equals(Object o) {
return o instanceof Dir && inode == ((Dir) o).inode;
}
@Override
public int hashCode() {
return Long.valueOf(inode).hashCode();
}
}
/**
* If the Dir entry does not exist (i.e. the inode was not contained in
* INodeSection) we still create a Dir entry which throws exceptions
* for calls other than getId().
* We can make sure this way, the getId and getParentId calls will
* always succeed if we have the information.
*/
private static class CorruptedDir extends Dir {
CorruptedDir(long inode) {
super(inode, null);
}
@Override
String getPath() throws IgnoreSnapshotException {
throw PBImageTextWriter.createIgnoredSnapshotException(getId());
}
@Override
String getName() throws IgnoreSnapshotException {
throw PBImageTextWriter.createIgnoredSnapshotException(getId());
}
}
/** INode Id to Dir object mapping */
private Map<Long, Dir> dirMap = new HashMap<>();
/** Children to parent directory INode ID mapping. */
private Map<Long, Dir> dirChildMap = new HashMap<>();
InMemoryMetadataDB() {
}
@Override
public void close() throws IOException {
}
private Dir getOrCreateCorrupted(long id) {
Dir dir = dirMap.get(id);
if (dir == null) {
dir = new CorruptedDir(id);
dirMap.put(id, dir);
}
return dir;
}
@Override
public void putDirChild(long parentId, long childId) {
Dir parent = getOrCreateCorrupted(parentId);
Dir child = getOrCreateCorrupted(childId);
child.setParent(parent);
Preconditions.checkState(!dirChildMap.containsKey(childId));
dirChildMap.put(childId, parent);
}
@Override
public void putDir(INode p) {
Preconditions.checkState(!dirMap.containsKey(p.getId()));
Dir dir = new Dir(p.getId(), p.getName().toStringUtf8());
dirMap.put(p.getId(), dir);
}
@Override
public String getParentPath(long inode) throws IOException {
if (inode == INodeId.ROOT_INODE_ID) {
return "/";
}
Dir parent = dirChildMap.get(inode);
if (parent == null) {
// The inode is an INodeReference, which is generated from snapshot.
// For delimited oiv tool, no need to print out metadata in snapshots.
throw PBImageTextWriter.createIgnoredSnapshotException(inode);
}
return parent.getPath();
}
@Override
public void sync() {
}
@Override
public String getName(long id) throws IgnoreSnapshotException {
Dir dir = dirMap.get(id);
if (dir != null) {
return dir.getName();
}
throw PBImageTextWriter.createIgnoredSnapshotException(id);
}
@Override
public long getParentId(long id) throws IgnoreSnapshotException {
Dir parentDir = dirChildMap.get(id);
if (parentDir != null) {
return parentDir.getId();
}
throw PBImageTextWriter.createIgnoredSnapshotException(id);
}
}
/**
* A MetadataMap that stores metadata in LevelDB.
*/
private static class LevelDBMetadataMap implements MetadataMap {
/**
* Store metadata in LevelDB.
*/
private static class LevelDBStore implements Closeable {
private DB db = null;
private WriteBatch batch = null;
private int writeCount = 0;
private static final int BATCH_SIZE = 1024;
LevelDBStore(final File dbPath) throws IOException {
Options options = new Options();
options.createIfMissing(true);
options.errorIfExists(true);
db = JniDBFactory.factory.open(dbPath, options);
batch = db.createWriteBatch();
}
@Override
public void close() throws IOException {
if (batch != null) {
IOUtils.cleanupWithLogger(null, batch);
batch = null;
}
IOUtils.cleanupWithLogger(null, db);
db = null;
}
public void put(byte[] key, byte[] value) throws IOException {
batch.put(key, value);
writeCount++;
if (writeCount >= BATCH_SIZE) {
sync();
}
}
public byte[] get(byte[] key) throws IOException {
return db.get(key);
}
public void sync() throws IOException {
try {
db.write(batch);
} finally {
batch.close();
batch = null;
}
batch = db.createWriteBatch();
writeCount = 0;
}
}
/**
* A LRU cache for directory path strings.
*
* The key of this LRU cache is the inode of a directory.
*/
private static class DirPathCache extends LinkedHashMap<Long, String> {
private final static int CAPACITY = 16 * 1024;
DirPathCache() {
super(CAPACITY);
}
@Override
protected boolean removeEldestEntry(Map.Entry<Long, String> entry) {
return super.size() > CAPACITY;
}
}
/** Map the child inode to the parent directory inode. */
private LevelDBStore dirChildMap = null;
/** Directory entry map */
private LevelDBStore dirMap = null;
private DirPathCache dirPathCache = new DirPathCache();
LevelDBMetadataMap(String baseDir) throws IOException {
File dbDir = new File(baseDir);
if (dbDir.exists()) {
throw new IOException("Folder " + dbDir + " already exists! Delete " +
"manually or provide another (not existing) directory!");
}
if (!dbDir.mkdirs()) {
throw new IOException("Failed to mkdir on " + dbDir);
}
try {
dirChildMap = new LevelDBStore(new File(dbDir, "dirChildMap"));
dirMap = new LevelDBStore(new File(dbDir, "dirMap"));
} catch (IOException e) {
LOG.error("Failed to open LevelDBs", e);
IOUtils.cleanupWithLogger(null, this);
}
}
@Override
public void close() throws IOException {
IOUtils.cleanupWithLogger(null, dirChildMap, dirMap);
dirChildMap = null;
dirMap = null;
}
private static byte[] toBytes(long value) {
return ByteBuffer.allocate(8).putLong(value).array();
}
private static byte[] toBytes(String value) {
return value.getBytes(StandardCharsets.UTF_8);
}
private static long toLong(byte[] bytes) {
Preconditions.checkArgument(bytes.length == 8);
return ByteBuffer.wrap(bytes).getLong();
}
private static String toString(byte[] bytes) throws IOException {
return new String(bytes, StandardCharsets.UTF_8);
}
@Override
public void putDirChild(long parentId, long childId) throws IOException {
dirChildMap.put(toBytes(childId), toBytes(parentId));
}
@Override
public void putDir(INode dir) throws IOException {
Preconditions.checkArgument(dir.hasDirectory(),
"INode %s (%s) is not a directory.", dir.getId(), dir.getName());
dirMap.put(toBytes(dir.getId()), toBytes(dir.getName().toStringUtf8()));
}
private long getFromDirChildMap(long inode) throws IOException {
byte[] bytes = dirChildMap.get(toBytes(inode));
if (bytes == null) {
// The inode is an INodeReference, which is generated from snapshot.
// For delimited oiv tool, no need to print out metadata in snapshots.
throw PBImageTextWriter.createIgnoredSnapshotException(inode);
}
if (bytes.length != 8) {
throw new IOException(
"bytes array length error. Actual length is " + bytes.length);
}
return toLong(bytes);
}
@Override
public String getParentPath(long inode) throws IOException {
if (inode == INodeId.ROOT_INODE_ID) {
return "/";
}
long parent = getFromDirChildMap(inode);
byte[] bytes = dirMap.get(toBytes(parent));
synchronized (this) {
if (!dirPathCache.containsKey(parent)) {
if (parent != INodeId.ROOT_INODE_ID && bytes == null) {
// The parent is an INodeReference, which is generated from snapshot.
// For delimited oiv tool, no need to print out metadata in snapshots.
throw PBImageTextWriter.createIgnoredSnapshotException(inode);
}
String parentName = toString(bytes);
String parentPath =
new Path(getParentPath(parent),
parentName.isEmpty() ? "/" : parentName).toString();
dirPathCache.put(parent, parentPath);
}
return dirPathCache.get(parent);
}
}
@Override
public void sync() throws IOException {
dirChildMap.sync();
dirMap.sync();
}
@Override
public String getName(long id) throws IOException {
byte[] bytes = dirMap.get(toBytes(id));
if (bytes != null) {
return toString(bytes);
}
throw PBImageTextWriter.createIgnoredSnapshotException(id);
}
@Override
public long getParentId(long id) throws IOException {
return getFromDirChildMap(id);
}
}
private SerialNumberManager.StringTable stringTable;
private final PrintStream out;
private MetadataMap metadataMap = null;
private String delimiter;
private File filename;
private int numThreads;
private String parallelOutputFile;
private final XAttr ecXAttr =
XAttrHelper.buildXAttr(XATTR_ERASURECODING_POLICY);
/**
* Construct a PB FsImage writer to generate text file.
* @param out the writer to output text information of fsimage.
* @param tempPath the path to store metadata. If it is empty, store metadata
* in memory instead.
*/
PBImageTextWriter(PrintStream out, String delimiter, String tempPath,
int numThreads, String parallelOutputFile) throws IOException {
this.out = out;
this.delimiter = delimiter;
if (tempPath.isEmpty()) {
metadataMap = new InMemoryMetadataDB();
} else {
metadataMap = new LevelDBMetadataMap(tempPath);
}
this.numThreads = numThreads;
this.parallelOutputFile = parallelOutputFile;
}
PBImageTextWriter(PrintStream out, String delimiter, String tempPath)
throws IOException {
this(out, delimiter, tempPath, 1, "-");
}
protected PrintStream serialOutStream() {
return out;
}
@Override
public void close() throws IOException {
out.flush();
IOUtils.cleanupWithLogger(null, metadataMap);
}
void append(StringBuffer buffer, int field) {
buffer.append(delimiter);
buffer.append(field);
}
void append(StringBuffer buffer, long field) {
buffer.append(delimiter);
buffer.append(field);
}
void append(StringBuffer buffer, String field) {
buffer.append(delimiter);
String escapedField = StringEscapeUtils.escapeCsv(field);
if (escapedField.contains(CRLF)) {
escapedField = escapedField.replace(CRLF, "%x0D%x0A");
} else if (escapedField.contains(StringUtils.LF)) {
escapedField = escapedField.replace(StringUtils.LF, "%x0A");
}
buffer.append(escapedField);
}
/**
* Get text output for the given inode.
* @param parent the path of parent directory
* @param inode the INode object to output.
*/
abstract protected String getEntry(String parent, INode inode);
/**
* Get text output for the header line.
*/
abstract protected String getHeader();
/**
* Method called at the end of output() phase after all the inodes
* with known parentPath has been printed out. Can be used to print
* additional data depending on the written inodes.
*/
abstract protected void afterOutput() throws IOException;
public void visit(String filePath) throws IOException {
filename = new File(filePath);
RandomAccessFile file = new RandomAccessFile(filePath, "r");
Configuration conf = new Configuration();
if (!FSImageUtil.checkFileFormat(file)) {
throw new IOException("Unrecognized FSImage");
}
FileSummary summary = FSImageUtil.loadSummary(file);
try (FileInputStream fin = new FileInputStream(file.getFD())) {
InputStream is;
ArrayList<FileSummary.Section> sections =
Lists.newArrayList(summary.getSectionsList());
Collections.sort(sections,
new Comparator<FileSummary.Section>() {
@Override
public int compare(FsImageProto.FileSummary.Section s1,
FsImageProto.FileSummary.Section s2) {
FSImageFormatProtobuf.SectionName n1 =
FSImageFormatProtobuf.SectionName.fromString(s1.getName());
FSImageFormatProtobuf.SectionName n2 =
FSImageFormatProtobuf.SectionName.fromString(s2.getName());
if (n1 == null) {
return n2 == null ? 0 : -1;
} else if (n2 == null) {
return -1;
} else {
return n1.ordinal() - n2.ordinal();
}
}
});
ImmutableList<Long> refIdList = null;
for (FileSummary.Section section : sections) {
fin.getChannel().position(section.getOffset());
is = FSImageUtil.wrapInputStreamForCompression(conf,
summary.getCodec(), new BufferedInputStream(new LimitInputStream(
fin, section.getLength())));
SectionName sectionName = SectionName.fromString(section.getName());
if (sectionName == null) {
throw new IOException("Unrecognized section " + section.getName());
}
switch (sectionName) {
case STRING_TABLE:
LOG.info("Loading string table");
stringTable = FSImageLoader.loadStringTable(is);
break;
case INODE_REFERENCE:
// Load INodeReference so that all INodes can be processed.
// Snapshots are not handled and will just be ignored for now.
LOG.info("Loading inode references");
refIdList = FSImageLoader.loadINodeReferenceSection(is);
break;
default:
break;
}
}
loadDirectories(fin, sections, summary, conf);
loadINodeDirSection(fin, sections, summary, conf, refIdList);
metadataMap.sync();
output(conf, summary, fin, sections);
}
}
void putDirChildToMetadataMap(long parentId, long childId)
throws IOException {
metadataMap.putDirChild(parentId, childId);
}
String getNodeName(long id) throws IOException {
return metadataMap.getName(id);
}
long getParentId(long id) throws IOException {
return metadataMap.getParentId(id);
}
private void output(Configuration conf, FileSummary summary,
FileInputStream fin, ArrayList<FileSummary.Section> sections)
throws IOException {
ArrayList<FileSummary.Section> allINodeSubSections =
getINodeSubSections(sections);
if (numThreads > 1 && !parallelOutputFile.equals("-") &&
allINodeSubSections.size() > 1) {
outputInParallel(conf, summary, allINodeSubSections);
} else {
LOG.info("Serial output due to threads num: {}, parallel output file: {}, " +
"subSections: {}.", numThreads, parallelOutputFile, allINodeSubSections.size());
outputInSerial(conf, summary, fin, sections);
}
}
private void outputInSerial(Configuration conf, FileSummary summary,
FileInputStream fin, ArrayList<FileSummary.Section> sections)
throws IOException {
InputStream is;
long startTime = Time.monotonicNow();
serialOutStream().println(getHeader());
for (FileSummary.Section section : sections) {
if (SectionName.fromString(section.getName()) == SectionName.INODE) {
fin.getChannel().position(section.getOffset());
is = FSImageUtil.wrapInputStreamForCompression(conf,
summary.getCodec(), new BufferedInputStream(new LimitInputStream(
fin, section.getLength())));
INodeSection s = INodeSection.parseDelimitedFrom(is);
LOG.info("Found {} INodes in the INode section", s.getNumInodes());
int count = outputINodes(is, serialOutStream());
LOG.info("Outputted {} INodes.", count);
}
}
afterOutput();
long timeTaken = Time.monotonicNow() - startTime;
LOG.debug("Time to output inodes: {} ms", timeTaken);
}
/**
* STEP1: Multi-threaded process sub-sections.
* Given n (n>1) threads to process k (k>=n) sections,
* output parsed results of each section to tmp file in order.
* STEP2: Merge tmp files.
*/
private void outputInParallel(Configuration conf, FileSummary summary,
ArrayList<FileSummary.Section> subSections)
throws IOException {
int nThreads = Integer.min(numThreads, subSections.size());
LOG.info("Outputting in parallel with {} sub-sections using {} threads",
subSections.size(), nThreads);
final CopyOnWriteArrayList<IOException> exceptions = new CopyOnWriteArrayList<>();
CountDownLatch latch = new CountDownLatch(subSections.size());
ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
AtomicLong expectedINodes = new AtomicLong(0);
AtomicLong totalParsed = new AtomicLong(0);
String codec = summary.getCodec();
String[] paths = new String[subSections.size()];
for (int i = 0; i < subSections.size(); i++) {
paths[i] = parallelOutputFile + ".tmp." + i;
int index = i;
executorService.submit(() -> {
LOG.info("Output iNodes of section-{}", index);
InputStream is = null;
try (PrintStream outStream = new PrintStream(paths[index], "UTF-8")) {
long startTime = Time.monotonicNow();
is = getInputStreamForSection(subSections.get(index), codec, conf);
if (index == 0) {
// The first iNode section has a header which must be processed first
INodeSection s = INodeSection.parseDelimitedFrom(is);
expectedINodes.set(s.getNumInodes());
}
totalParsed.addAndGet(outputINodes(is, outStream));
long timeTaken = Time.monotonicNow() - startTime;
LOG.info("Time to output iNodes of section-{}: {} ms", index, timeTaken);
} catch (Exception e) {
exceptions.add(new IOException(e));
} finally {
latch.countDown();
try {
if (is != null) {
is.close();
}
} catch (IOException ioe) {
LOG.warn("Failed to close the input stream, ignoring", ioe);
}
}
});
}
try {
latch.await();
} catch (InterruptedException e) {
LOG.error("Interrupted waiting for countdown latch", e);
throw new IOException(e);
}
executorService.shutdown();
if (exceptions.size() != 0) {
LOG.error("Failed to output INode sub-sections, {} exception(s) occurred.",
exceptions.size());
throw exceptions.get(0);
}
if (totalParsed.get() != expectedINodes.get()) {
throw new IOException("Expected to parse " + expectedINodes + " in parallel, " +
"but parsed " + totalParsed.get() + ". The image may be corrupt.");
}
LOG.info("Completed outputting all INode sub-sections to {} tmp files.",
subSections.size());
try (PrintStream ps = new PrintStream(parallelOutputFile, "UTF-8")) {
ps.println(getHeader());
}
// merge tmp files
long startTime = Time.monotonicNow();
mergeFiles(paths, parallelOutputFile);
long timeTaken = Time.monotonicNow() - startTime;
LOG.info("Completed all stages. Time to merge files: {} ms", timeTaken);
}
protected PermissionStatus getPermission(long perm) {
return FSImageFormatPBINode.Loader.loadPermission(perm, stringTable);
}
/** Load the directories in the INode section. */
private void loadDirectories(
FileInputStream fin, List<FileSummary.Section> sections,
FileSummary summary, Configuration conf)
throws IOException {
LOG.info("Loading directories");
long startTime = Time.monotonicNow();
for (FileSummary.Section section : sections) {
if (SectionName.fromString(section.getName())
== SectionName.INODE) {
fin.getChannel().position(section.getOffset());
InputStream is = FSImageUtil.wrapInputStreamForCompression(conf,
summary.getCodec(), new BufferedInputStream(new LimitInputStream(
fin, section.getLength())));
loadDirectoriesInINodeSection(is);
}
}
long timeTaken = Time.monotonicNow() - startTime;
LOG.info("Finished loading directories in {}ms", timeTaken);
}
private void loadINodeDirSection(
FileInputStream fin, List<FileSummary.Section> sections,
FileSummary summary, Configuration conf, List<Long> refIdList)
throws IOException {
LOG.info("Loading INode directory section.");
long startTime = Time.monotonicNow();
for (FileSummary.Section section : sections) {
if (SectionName.fromString(section.getName())
== SectionName.INODE_DIR) {
fin.getChannel().position(section.getOffset());
InputStream is = FSImageUtil.wrapInputStreamForCompression(conf,
summary.getCodec(), new BufferedInputStream(
new LimitInputStream(fin, section.getLength())));
buildNamespace(is, refIdList);
}
}
long timeTaken = Time.monotonicNow() - startTime;
LOG.info("Finished loading INode directory section in {}ms", timeTaken);
}
/**
* Checks the inode (saves if directory), and counts them. Can be overridden
* if additional steps are taken when iterating through INodeSection.
*/
protected void checkNode(INode p, AtomicInteger numDirs) throws IOException {
if (p.hasDirectory()) {
metadataMap.putDir(p);
numDirs.incrementAndGet();
}
}
/**
* Load the filenames of the directories from the INode section.
*/
private void loadDirectoriesInINodeSection(InputStream in)
throws IOException {
INodeSection s = INodeSection.parseDelimitedFrom(in);
LOG.info("Loading directories in INode section.");
AtomicInteger numDirs = new AtomicInteger(0);
for (int i = 0; i < s.getNumInodes(); ++i) {
INode p = INode.parseDelimitedFrom(in);
if (LOG.isDebugEnabled() && i % 10000 == 0) {
LOG.debug("Scanned {} inodes.", i);
}
checkNode(p, numDirs);
}
LOG.info("Found {} directories in INode section.", numDirs);
}
/**
* Scan the INodeDirectory section to construct the namespace.
*/
protected void buildNamespace(InputStream in, List<Long> refIdList)
throws IOException {
int count = 0;
while (true) {
FsImageProto.INodeDirectorySection.DirEntry e =
FsImageProto.INodeDirectorySection.DirEntry.parseDelimitedFrom(in);
if (e == null) {
break;
}
count++;
if (LOG.isDebugEnabled() && count % 10000 == 0) {
LOG.debug("Scanned {} directories.", count);
}
long parentId = e.getParent();
for (int i = 0; i < e.getChildrenCount(); i++) {
long childId = e.getChildren(i);
metadataMap.putDirChild(parentId, childId);
}
for (int i = e.getChildrenCount();
i < e.getChildrenCount() + e.getRefChildrenCount(); i++) {
int refId = e.getRefChildren(i - e.getChildrenCount());
metadataMap.putDirChild(parentId, refIdList.get(refId));
}
}
LOG.info("Scanned {} INode directories to build namespace.", count);
}
void printIfNotEmpty(PrintStream outStream, String line) {
if (!line.isEmpty()) {
outStream.println(line);
}
}
private int outputINodes(InputStream in, PrintStream outStream)
throws IOException {
long ignored = 0;
long ignoredSnapshots = 0;
// As the input stream is a LimitInputStream, the reading will stop when
// EOF is encountered at the end of the stream.
int count = 0;
while (true) {
INode p = INode.parseDelimitedFrom(in);
if (p == null) {
break;
}
try {
String parentPath = metadataMap.getParentPath(p.getId());
printIfNotEmpty(outStream, getEntry(parentPath, p));
} catch (IOException ioe) {
ignored++;
if (!(ioe instanceof IgnoreSnapshotException)) {
LOG.warn("Exception caught, ignoring node:{}", p.getId(), ioe);
} else {
ignoredSnapshots++;
if (LOG.isDebugEnabled()) {
LOG.debug("Exception caught, ignoring node:{}.", p.getId(), ioe);
}
}
}
count++;
if (LOG.isDebugEnabled() && count % 100000 == 0) {
LOG.debug("Outputted {} INodes.", count);
}
}
if (ignored > 0) {
LOG.warn("Ignored {} nodes, including {} in snapshots. Please turn on"
+ " debug log for details", ignored, ignoredSnapshots);
}
return count;
}
private static IgnoreSnapshotException createIgnoredSnapshotException(
long inode) {
// Ignore snapshots - we want the output similar to -ls -R.
if (LOG.isDebugEnabled()) {
LOG.debug("No snapshot name found for inode {}", inode);
}
return new IgnoreSnapshotException();
}
public int getStoragePolicy(
INodeSection.XAttrFeatureProto xattrFeatureProto) {
List<XAttr> xattrs =
FSImageFormatPBINode.Loader.loadXAttrs(xattrFeatureProto, stringTable);
for (XAttr xattr : xattrs) {
if (BlockStoragePolicySuite.isStoragePolicyXAttr(xattr)) {
return xattr.getValue()[0];
}
}
return HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED;
}
private ArrayList<FileSummary.Section> getINodeSubSections(
ArrayList<FileSummary.Section> sections) {
ArrayList<FileSummary.Section> subSections = new ArrayList<>();
Iterator<FileSummary.Section> iter = sections.iterator();
while (iter.hasNext()) {
FileSummary.Section s = iter.next();
if (SectionName.fromString(s.getName()) == SectionName.INODE_SUB) {
subSections.add(s);
}
}
return subSections;
}
/**
* Given a FSImage FileSummary.section, return a LimitInput stream set to
* the starting position of the section and limited to the section length.
* @param section The FileSummary.Section containing the offset and length
* @param compressionCodec The compression codec in use, if any
* @return An InputStream for the given section
* @throws IOException
*/
private InputStream getInputStreamForSection(FileSummary.Section section,
String compressionCodec, Configuration conf)
throws IOException {
// channel of RandomAccessFile is not thread safe, use File
FileInputStream fin = new FileInputStream(filename);
try {
FileChannel channel = fin.getChannel();
channel.position(section.getOffset());
InputStream in = new BufferedInputStream(new LimitInputStream(fin,
section.getLength()));
in = FSImageUtil.wrapInputStreamForCompression(conf,
compressionCodec, in);
return in;
} catch (IOException e) {
fin.close();
throw e;
}
}
/**
* @param srcPaths Source files of contents to be merged
* @param resultPath Merged file path
* @throws IOException
*/
public static void mergeFiles(String[] srcPaths, String resultPath)
throws IOException {
if (srcPaths == null || srcPaths.length < 1) {
LOG.warn("no source files to merge.");
return;
}
File[] files = new File[srcPaths.length];
for (int i = 0; i < srcPaths.length; i++) {
files[i] = new File(srcPaths[i]);
}
File resultFile = new File(resultPath);
try (FileChannel resultChannel =
new FileOutputStream(resultFile, true).getChannel()) {
for (File file : files) {
try (FileChannel src = new FileInputStream(file).getChannel()) {
resultChannel.transferFrom(src, resultChannel.size(), src.size());
}
}
}
for (File file : files) {
if (!file.delete() && file.exists()) {
LOG.warn("delete tmp file: {} returned false", file);
}
}
}
public String getErasureCodingPolicyName
(INodeSection.XAttrFeatureProto xattrFeatureProto) {
List<XAttr> xattrs =
FSImageFormatPBINode.Loader.loadXAttrs(xattrFeatureProto, stringTable);
for (XAttr xattr : xattrs) {
if (xattr.equalsIgnoreValue(ecXAttr)){
try{
ByteArrayInputStream bIn = new ByteArrayInputStream(xattr.getValue());
DataInputStream dIn = new DataInputStream(bIn);
return WritableUtils.readString(dIn);
} catch (IOException ioException){
return null;
}
}
}
return null;
}
}
|
googleapis/google-cloud-java | 36,335 | java-visionai/proto-google-cloud-visionai-v1/src/main/java/com/google/cloud/visionai/v1/UpdateIndexRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/visionai/v1/warehouse.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.visionai.v1;
/**
*
*
* <pre>
* Request message for UpdateIndex.
* </pre>
*
* Protobuf type {@code google.cloud.visionai.v1.UpdateIndexRequest}
*/
public final class UpdateIndexRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.visionai.v1.UpdateIndexRequest)
UpdateIndexRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateIndexRequest.newBuilder() to construct.
private UpdateIndexRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateIndexRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateIndexRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateIndexRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateIndexRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.visionai.v1.UpdateIndexRequest.class,
com.google.cloud.visionai.v1.UpdateIndexRequest.Builder.class);
}
private int bitField0_;
public static final int INDEX_FIELD_NUMBER = 1;
private com.google.cloud.visionai.v1.Index index_;
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the index field is set.
*/
@java.lang.Override
public boolean hasIndex() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The index.
*/
@java.lang.Override
public com.google.cloud.visionai.v1.Index getIndex() {
return index_ == null ? com.google.cloud.visionai.v1.Index.getDefaultInstance() : index_;
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.visionai.v1.IndexOrBuilder getIndexOrBuilder() {
return index_ == null ? com.google.cloud.visionai.v1.Index.getDefaultInstance() : index_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getIndex());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getIndex());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.visionai.v1.UpdateIndexRequest)) {
return super.equals(obj);
}
com.google.cloud.visionai.v1.UpdateIndexRequest other =
(com.google.cloud.visionai.v1.UpdateIndexRequest) obj;
if (hasIndex() != other.hasIndex()) return false;
if (hasIndex()) {
if (!getIndex().equals(other.getIndex())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasIndex()) {
hash = (37 * hash) + INDEX_FIELD_NUMBER;
hash = (53 * hash) + getIndex().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest 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.visionai.v1.UpdateIndexRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest 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.visionai.v1.UpdateIndexRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest 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.visionai.v1.UpdateIndexRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest 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.visionai.v1.UpdateIndexRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest 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.visionai.v1.UpdateIndexRequest 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;
}
/**
*
*
* <pre>
* Request message for UpdateIndex.
* </pre>
*
* Protobuf type {@code google.cloud.visionai.v1.UpdateIndexRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.visionai.v1.UpdateIndexRequest)
com.google.cloud.visionai.v1.UpdateIndexRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateIndexRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateIndexRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.visionai.v1.UpdateIndexRequest.class,
com.google.cloud.visionai.v1.UpdateIndexRequest.Builder.class);
}
// Construct using com.google.cloud.visionai.v1.UpdateIndexRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getIndexFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
index_ = null;
if (indexBuilder_ != null) {
indexBuilder_.dispose();
indexBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateIndexRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateIndexRequest getDefaultInstanceForType() {
return com.google.cloud.visionai.v1.UpdateIndexRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateIndexRequest build() {
com.google.cloud.visionai.v1.UpdateIndexRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateIndexRequest buildPartial() {
com.google.cloud.visionai.v1.UpdateIndexRequest result =
new com.google.cloud.visionai.v1.UpdateIndexRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.visionai.v1.UpdateIndexRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.index_ = indexBuilder_ == null ? index_ : indexBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.visionai.v1.UpdateIndexRequest) {
return mergeFrom((com.google.cloud.visionai.v1.UpdateIndexRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.visionai.v1.UpdateIndexRequest other) {
if (other == com.google.cloud.visionai.v1.UpdateIndexRequest.getDefaultInstance())
return this;
if (other.hasIndex()) {
mergeIndex(other.getIndex());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(getIndexFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.cloud.visionai.v1.Index index_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.visionai.v1.Index,
com.google.cloud.visionai.v1.Index.Builder,
com.google.cloud.visionai.v1.IndexOrBuilder>
indexBuilder_;
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the index field is set.
*/
public boolean hasIndex() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The index.
*/
public com.google.cloud.visionai.v1.Index getIndex() {
if (indexBuilder_ == null) {
return index_ == null ? com.google.cloud.visionai.v1.Index.getDefaultInstance() : index_;
} else {
return indexBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setIndex(com.google.cloud.visionai.v1.Index value) {
if (indexBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
index_ = value;
} else {
indexBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setIndex(com.google.cloud.visionai.v1.Index.Builder builderForValue) {
if (indexBuilder_ == null) {
index_ = builderForValue.build();
} else {
indexBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeIndex(com.google.cloud.visionai.v1.Index value) {
if (indexBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& index_ != null
&& index_ != com.google.cloud.visionai.v1.Index.getDefaultInstance()) {
getIndexBuilder().mergeFrom(value);
} else {
index_ = value;
}
} else {
indexBuilder_.mergeFrom(value);
}
if (index_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearIndex() {
bitField0_ = (bitField0_ & ~0x00000001);
index_ = null;
if (indexBuilder_ != null) {
indexBuilder_.dispose();
indexBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.visionai.v1.Index.Builder getIndexBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getIndexFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.visionai.v1.IndexOrBuilder getIndexOrBuilder() {
if (indexBuilder_ != null) {
return indexBuilder_.getMessageOrBuilder();
} else {
return index_ == null ? com.google.cloud.visionai.v1.Index.getDefaultInstance() : index_;
}
}
/**
*
*
* <pre>
* Required. The resource being updated.
* </pre>
*
* <code>.google.cloud.visionai.v1.Index index = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.visionai.v1.Index,
com.google.cloud.visionai.v1.Index.Builder,
com.google.cloud.visionai.v1.IndexOrBuilder>
getIndexFieldBuilder() {
if (indexBuilder_ == null) {
indexBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.visionai.v1.Index,
com.google.cloud.visionai.v1.Index.Builder,
com.google.cloud.visionai.v1.IndexOrBuilder>(
getIndex(), getParentForChildren(), isClean());
index_ = null;
}
return indexBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* Required. Field mask is used to specify the fields to be overwritten in the
* Index resource by the update. The fields specified in the update_mask are
* relative to the resource, not the full request. A field of the resource
* will be overwritten if it is in the mask. Empty field mask is not allowed.
* If the mask is "*", it triggers a full update of the index, and also a
* whole rebuild of index data.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.visionai.v1.UpdateIndexRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.visionai.v1.UpdateIndexRequest)
private static final com.google.cloud.visionai.v1.UpdateIndexRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.visionai.v1.UpdateIndexRequest();
}
public static com.google.cloud.visionai.v1.UpdateIndexRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateIndexRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateIndexRequest>() {
@java.lang.Override
public UpdateIndexRequest 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<UpdateIndexRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateIndexRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateIndexRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,380 | java-alloydb/proto-google-cloud-alloydb-v1beta/src/main/java/com/google/cloud/alloydb/v1beta/CreateInstanceRequests.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/alloydb/v1beta/service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.alloydb.v1beta;
/**
*
*
* <pre>
* See usage below for notes.
* </pre>
*
* Protobuf type {@code google.cloud.alloydb.v1beta.CreateInstanceRequests}
*/
public final class CreateInstanceRequests extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.alloydb.v1beta.CreateInstanceRequests)
CreateInstanceRequestsOrBuilder {
private static final long serialVersionUID = 0L;
// Use CreateInstanceRequests.newBuilder() to construct.
private CreateInstanceRequests(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private CreateInstanceRequests() {
createInstanceRequests_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new CreateInstanceRequests();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.alloydb.v1beta.ServiceProto
.internal_static_google_cloud_alloydb_v1beta_CreateInstanceRequests_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.alloydb.v1beta.ServiceProto
.internal_static_google_cloud_alloydb_v1beta_CreateInstanceRequests_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.alloydb.v1beta.CreateInstanceRequests.class,
com.google.cloud.alloydb.v1beta.CreateInstanceRequests.Builder.class);
}
public static final int CREATE_INSTANCE_REQUESTS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.alloydb.v1beta.CreateInstanceRequest>
createInstanceRequests_;
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.alloydb.v1beta.CreateInstanceRequest>
getCreateInstanceRequestsList() {
return createInstanceRequests_;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public java.util.List<? extends com.google.cloud.alloydb.v1beta.CreateInstanceRequestOrBuilder>
getCreateInstanceRequestsOrBuilderList() {
return createInstanceRequests_;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public int getCreateInstanceRequestsCount() {
return createInstanceRequests_.size();
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.alloydb.v1beta.CreateInstanceRequest getCreateInstanceRequests(
int index) {
return createInstanceRequests_.get(index);
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.alloydb.v1beta.CreateInstanceRequestOrBuilder
getCreateInstanceRequestsOrBuilder(int index) {
return createInstanceRequests_.get(index);
}
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 {
for (int i = 0; i < createInstanceRequests_.size(); i++) {
output.writeMessage(1, createInstanceRequests_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < createInstanceRequests_.size(); i++) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
1, createInstanceRequests_.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.alloydb.v1beta.CreateInstanceRequests)) {
return super.equals(obj);
}
com.google.cloud.alloydb.v1beta.CreateInstanceRequests other =
(com.google.cloud.alloydb.v1beta.CreateInstanceRequests) obj;
if (!getCreateInstanceRequestsList().equals(other.getCreateInstanceRequestsList()))
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 (getCreateInstanceRequestsCount() > 0) {
hash = (37 * hash) + CREATE_INSTANCE_REQUESTS_FIELD_NUMBER;
hash = (53 * hash) + getCreateInstanceRequestsList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests 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.alloydb.v1beta.CreateInstanceRequests parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests 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.alloydb.v1beta.CreateInstanceRequests parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests 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.alloydb.v1beta.CreateInstanceRequests parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests 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.alloydb.v1beta.CreateInstanceRequests parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests 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.alloydb.v1beta.CreateInstanceRequests 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;
}
/**
*
*
* <pre>
* See usage below for notes.
* </pre>
*
* Protobuf type {@code google.cloud.alloydb.v1beta.CreateInstanceRequests}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.alloydb.v1beta.CreateInstanceRequests)
com.google.cloud.alloydb.v1beta.CreateInstanceRequestsOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.alloydb.v1beta.ServiceProto
.internal_static_google_cloud_alloydb_v1beta_CreateInstanceRequests_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.alloydb.v1beta.ServiceProto
.internal_static_google_cloud_alloydb_v1beta_CreateInstanceRequests_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.alloydb.v1beta.CreateInstanceRequests.class,
com.google.cloud.alloydb.v1beta.CreateInstanceRequests.Builder.class);
}
// Construct using com.google.cloud.alloydb.v1beta.CreateInstanceRequests.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (createInstanceRequestsBuilder_ == null) {
createInstanceRequests_ = java.util.Collections.emptyList();
} else {
createInstanceRequests_ = null;
createInstanceRequestsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.alloydb.v1beta.ServiceProto
.internal_static_google_cloud_alloydb_v1beta_CreateInstanceRequests_descriptor;
}
@java.lang.Override
public com.google.cloud.alloydb.v1beta.CreateInstanceRequests getDefaultInstanceForType() {
return com.google.cloud.alloydb.v1beta.CreateInstanceRequests.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.alloydb.v1beta.CreateInstanceRequests build() {
com.google.cloud.alloydb.v1beta.CreateInstanceRequests result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.alloydb.v1beta.CreateInstanceRequests buildPartial() {
com.google.cloud.alloydb.v1beta.CreateInstanceRequests result =
new com.google.cloud.alloydb.v1beta.CreateInstanceRequests(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.alloydb.v1beta.CreateInstanceRequests result) {
if (createInstanceRequestsBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
createInstanceRequests_ = java.util.Collections.unmodifiableList(createInstanceRequests_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.createInstanceRequests_ = createInstanceRequests_;
} else {
result.createInstanceRequests_ = createInstanceRequestsBuilder_.build();
}
}
private void buildPartial0(com.google.cloud.alloydb.v1beta.CreateInstanceRequests result) {
int from_bitField0_ = bitField0_;
}
@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.alloydb.v1beta.CreateInstanceRequests) {
return mergeFrom((com.google.cloud.alloydb.v1beta.CreateInstanceRequests) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.alloydb.v1beta.CreateInstanceRequests other) {
if (other == com.google.cloud.alloydb.v1beta.CreateInstanceRequests.getDefaultInstance())
return this;
if (createInstanceRequestsBuilder_ == null) {
if (!other.createInstanceRequests_.isEmpty()) {
if (createInstanceRequests_.isEmpty()) {
createInstanceRequests_ = other.createInstanceRequests_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.addAll(other.createInstanceRequests_);
}
onChanged();
}
} else {
if (!other.createInstanceRequests_.isEmpty()) {
if (createInstanceRequestsBuilder_.isEmpty()) {
createInstanceRequestsBuilder_.dispose();
createInstanceRequestsBuilder_ = null;
createInstanceRequests_ = other.createInstanceRequests_;
bitField0_ = (bitField0_ & ~0x00000001);
createInstanceRequestsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getCreateInstanceRequestsFieldBuilder()
: null;
} else {
createInstanceRequestsBuilder_.addAllMessages(other.createInstanceRequests_);
}
}
}
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 10:
{
com.google.cloud.alloydb.v1beta.CreateInstanceRequest m =
input.readMessage(
com.google.cloud.alloydb.v1beta.CreateInstanceRequest.parser(),
extensionRegistry);
if (createInstanceRequestsBuilder_ == null) {
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.add(m);
} else {
createInstanceRequestsBuilder_.addMessage(m);
}
break;
} // case 10
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.alloydb.v1beta.CreateInstanceRequest>
createInstanceRequests_ = java.util.Collections.emptyList();
private void ensureCreateInstanceRequestsIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
createInstanceRequests_ =
new java.util.ArrayList<com.google.cloud.alloydb.v1beta.CreateInstanceRequest>(
createInstanceRequests_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.alloydb.v1beta.CreateInstanceRequest,
com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder,
com.google.cloud.alloydb.v1beta.CreateInstanceRequestOrBuilder>
createInstanceRequestsBuilder_;
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public java.util.List<com.google.cloud.alloydb.v1beta.CreateInstanceRequest>
getCreateInstanceRequestsList() {
if (createInstanceRequestsBuilder_ == null) {
return java.util.Collections.unmodifiableList(createInstanceRequests_);
} else {
return createInstanceRequestsBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public int getCreateInstanceRequestsCount() {
if (createInstanceRequestsBuilder_ == null) {
return createInstanceRequests_.size();
} else {
return createInstanceRequestsBuilder_.getCount();
}
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.alloydb.v1beta.CreateInstanceRequest getCreateInstanceRequests(
int index) {
if (createInstanceRequestsBuilder_ == null) {
return createInstanceRequests_.get(index);
} else {
return createInstanceRequestsBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setCreateInstanceRequests(
int index, com.google.cloud.alloydb.v1beta.CreateInstanceRequest value) {
if (createInstanceRequestsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.set(index, value);
onChanged();
} else {
createInstanceRequestsBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setCreateInstanceRequests(
int index, com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder builderForValue) {
if (createInstanceRequestsBuilder_ == null) {
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.set(index, builderForValue.build());
onChanged();
} else {
createInstanceRequestsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder addCreateInstanceRequests(
com.google.cloud.alloydb.v1beta.CreateInstanceRequest value) {
if (createInstanceRequestsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.add(value);
onChanged();
} else {
createInstanceRequestsBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder addCreateInstanceRequests(
int index, com.google.cloud.alloydb.v1beta.CreateInstanceRequest value) {
if (createInstanceRequestsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.add(index, value);
onChanged();
} else {
createInstanceRequestsBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder addCreateInstanceRequests(
com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder builderForValue) {
if (createInstanceRequestsBuilder_ == null) {
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.add(builderForValue.build());
onChanged();
} else {
createInstanceRequestsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder addCreateInstanceRequests(
int index, com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder builderForValue) {
if (createInstanceRequestsBuilder_ == null) {
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.add(index, builderForValue.build());
onChanged();
} else {
createInstanceRequestsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder addAllCreateInstanceRequests(
java.lang.Iterable<? extends com.google.cloud.alloydb.v1beta.CreateInstanceRequest>
values) {
if (createInstanceRequestsBuilder_ == null) {
ensureCreateInstanceRequestsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, createInstanceRequests_);
onChanged();
} else {
createInstanceRequestsBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearCreateInstanceRequests() {
if (createInstanceRequestsBuilder_ == null) {
createInstanceRequests_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
createInstanceRequestsBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder removeCreateInstanceRequests(int index) {
if (createInstanceRequestsBuilder_ == null) {
ensureCreateInstanceRequestsIsMutable();
createInstanceRequests_.remove(index);
onChanged();
} else {
createInstanceRequestsBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder
getCreateInstanceRequestsBuilder(int index) {
return getCreateInstanceRequestsFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.alloydb.v1beta.CreateInstanceRequestOrBuilder
getCreateInstanceRequestsOrBuilder(int index) {
if (createInstanceRequestsBuilder_ == null) {
return createInstanceRequests_.get(index);
} else {
return createInstanceRequestsBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public java.util.List<? extends com.google.cloud.alloydb.v1beta.CreateInstanceRequestOrBuilder>
getCreateInstanceRequestsOrBuilderList() {
if (createInstanceRequestsBuilder_ != null) {
return createInstanceRequestsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(createInstanceRequests_);
}
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder
addCreateInstanceRequestsBuilder() {
return getCreateInstanceRequestsFieldBuilder()
.addBuilder(com.google.cloud.alloydb.v1beta.CreateInstanceRequest.getDefaultInstance());
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder
addCreateInstanceRequestsBuilder(int index) {
return getCreateInstanceRequestsFieldBuilder()
.addBuilder(
index, com.google.cloud.alloydb.v1beta.CreateInstanceRequest.getDefaultInstance());
}
/**
*
*
* <pre>
* Required. Primary and read replica instances to be created. This list
* should not be empty.
* </pre>
*
* <code>
* repeated .google.cloud.alloydb.v1beta.CreateInstanceRequest create_instance_requests = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public java.util.List<com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder>
getCreateInstanceRequestsBuilderList() {
return getCreateInstanceRequestsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.alloydb.v1beta.CreateInstanceRequest,
com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder,
com.google.cloud.alloydb.v1beta.CreateInstanceRequestOrBuilder>
getCreateInstanceRequestsFieldBuilder() {
if (createInstanceRequestsBuilder_ == null) {
createInstanceRequestsBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.alloydb.v1beta.CreateInstanceRequest,
com.google.cloud.alloydb.v1beta.CreateInstanceRequest.Builder,
com.google.cloud.alloydb.v1beta.CreateInstanceRequestOrBuilder>(
createInstanceRequests_,
((bitField0_ & 0x00000001) != 0),
getParentForChildren(),
isClean());
createInstanceRequests_ = null;
}
return createInstanceRequestsBuilder_;
}
@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.alloydb.v1beta.CreateInstanceRequests)
}
// @@protoc_insertion_point(class_scope:google.cloud.alloydb.v1beta.CreateInstanceRequests)
private static final com.google.cloud.alloydb.v1beta.CreateInstanceRequests DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.alloydb.v1beta.CreateInstanceRequests();
}
public static com.google.cloud.alloydb.v1beta.CreateInstanceRequests getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<CreateInstanceRequests> PARSER =
new com.google.protobuf.AbstractParser<CreateInstanceRequests>() {
@java.lang.Override
public CreateInstanceRequests 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<CreateInstanceRequests> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<CreateInstanceRequests> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.alloydb.v1beta.CreateInstanceRequests getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/incubator-hugegraph | 36,329 | hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/HugeTraverser.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hugegraph.traversal.algorithm;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.hugegraph.HugeException;
import org.apache.hugegraph.HugeGraph;
import org.apache.hugegraph.backend.id.Id;
import org.apache.hugegraph.backend.query.Aggregate;
import org.apache.hugegraph.backend.query.ConditionQuery;
import org.apache.hugegraph.backend.query.EdgesQueryIterator;
import org.apache.hugegraph.backend.query.Query;
import org.apache.hugegraph.backend.query.QueryResults;
import org.apache.hugegraph.backend.tx.GraphTransaction;
import org.apache.hugegraph.config.CoreOptions;
import org.apache.hugegraph.exception.NotFoundException;
import org.apache.hugegraph.iterator.ExtendableIterator;
import org.apache.hugegraph.iterator.FilterIterator;
import org.apache.hugegraph.iterator.LimitIterator;
import org.apache.hugegraph.iterator.MapperIterator;
import org.apache.hugegraph.perf.PerfUtil.Watched;
import org.apache.hugegraph.schema.SchemaLabel;
import org.apache.hugegraph.structure.HugeEdge;
import org.apache.hugegraph.structure.HugeVertex;
import org.apache.hugegraph.traversal.algorithm.iterator.NestedIterator;
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
import org.apache.hugegraph.traversal.algorithm.steps.Steps;
import org.apache.hugegraph.traversal.optimize.TraversalUtil;
import org.apache.hugegraph.type.HugeType;
import org.apache.hugegraph.type.define.CollectionType;
import org.apache.hugegraph.type.define.Directions;
import org.apache.hugegraph.type.define.HugeKeys;
import org.apache.hugegraph.util.CollectionUtil;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.InsertionOrderUtil;
import org.apache.hugegraph.util.Log;
import org.apache.hugegraph.util.collection.CollectionFactory;
import org.apache.hugegraph.util.collection.ObjectIntMapping;
import org.apache.hugegraph.util.collection.ObjectIntMappingFactory;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
import org.slf4j.Logger;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
public class HugeTraverser {
public static final String DEFAULT_CAPACITY = "10000000";
public static final String DEFAULT_ELEMENTS_LIMIT = "10000000";
public static final String DEFAULT_PATHS_LIMIT = "10";
public static final String DEFAULT_LIMIT = "100";
public static final String DEFAULT_MAX_DEGREE = "10000";
public static final String DEFAULT_SKIP_DEGREE = "100000";
public static final String DEFAULT_SAMPLE = "100";
public static final String DEFAULT_WEIGHT = "0";
public static final int DEFAULT_MAX_DEPTH = 5000;
// Empirical value of scan limit, with which results can be returned in 3s
public static final String DEFAULT_PAGE_LIMIT = "100000";
public static final long NO_LIMIT = -1L;
// traverse mode of kout algorithm: bfs and dfs
public static final String TRAVERSE_MODE_BFS = "breadth_first_search";
public static final String TRAVERSE_MODE_DFS = "depth_first_search";
protected static final Logger LOG = Log.logger(HugeTraverser.class);
protected static final int MAX_VERTICES = 10;
private static CollectionFactory collectionFactory;
private final HugeGraph graph;
// for apimeasure
public AtomicLong edgeIterCounter = new AtomicLong(0);
public AtomicLong vertexIterCounter = new AtomicLong(0);
public HugeTraverser(HugeGraph graph) {
this.graph = graph;
if (collectionFactory == null) {
collectionFactory = new CollectionFactory(this.collectionType());
}
}
public static void checkDegree(long degree) {
checkPositiveOrNoLimit(degree, "max degree");
}
public static void checkCapacity(long capacity) {
checkPositiveOrNoLimit(capacity, "capacity");
}
public static void checkLimit(long limit) {
checkPositiveOrNoLimit(limit, "limit");
}
public static void checkPositive(long value, String name) {
E.checkArgument(value > 0,
"The %s parameter must be > 0, but got %s",
name, value);
}
public static void checkPositiveOrNoLimit(long value, String name) {
E.checkArgument(value > 0L || value == NO_LIMIT,
"The %s parameter must be > 0 or == %s, but got: %s",
name, NO_LIMIT, value);
}
public static void checkNonNegative(long value, String name) {
E.checkArgument(value >= 0L,
"The %s parameter must be >= 0, but got: %s",
name, value);
}
public static void checkNonNegativeOrNoLimit(long value, String name) {
E.checkArgument(value >= 0L || value == NO_LIMIT,
"The %s parameter must be >= 0 or == %s, but got: %s",
name, NO_LIMIT, value);
}
public static void checkCapacity(long capacity, long access,
String traverse) {
if (capacity != NO_LIMIT && access > capacity) {
throw new HugeException("Exceed capacity '%s' while finding %s",
capacity, traverse);
}
}
public static void checkSkipDegree(long skipDegree, long degree,
long capacity) {
E.checkArgument(skipDegree >= 0L &&
skipDegree <= Query.DEFAULT_CAPACITY,
"The skipped degree must be in [0, %s], but got '%s'",
Query.DEFAULT_CAPACITY, skipDegree);
if (capacity != NO_LIMIT) {
E.checkArgument(degree != NO_LIMIT && degree < capacity,
"The max degree must be < capacity");
E.checkArgument(skipDegree < capacity,
"The skipped degree must be < capacity");
}
if (skipDegree > 0L) {
E.checkArgument(degree != NO_LIMIT && skipDegree >= degree,
"The skipped degree must be >= max degree, " +
"but got skipped degree '%s' and max degree '%s'",
skipDegree, degree);
}
}
public static void checkTraverseMode(String traverseMode) {
E.checkArgument(traverseMode.compareToIgnoreCase(TRAVERSE_MODE_BFS) == 0 ||
traverseMode.compareToIgnoreCase(TRAVERSE_MODE_DFS) == 0,
"The traverse mode must be one of '%s' or '%s', but got '%s'",
TRAVERSE_MODE_BFS, TRAVERSE_MODE_DFS, traverseMode);
}
public static boolean isTraverseModeDFS(String traverseMode) {
return traverseMode.compareToIgnoreCase(TRAVERSE_MODE_DFS) == 0;
}
public static <K, V extends Comparable<? super V>> Map<K, V> topN(
Map<K, V> map,
boolean sorted,
long limit) {
if (sorted) {
map = CollectionUtil.sortByValue(map, false);
}
if (limit == NO_LIMIT || map.size() <= limit) {
return map;
}
Map<K, V> results = InsertionOrderUtil.newMap();
long count = 0L;
for (Map.Entry<K, V> entry : map.entrySet()) {
results.put(entry.getKey(), entry.getValue());
if (++count >= limit) {
break;
}
}
return results;
}
public static Iterator<Edge> skipSuperNodeIfNeeded(Iterator<Edge> edges,
long degree,
long skipDegree) {
if (skipDegree <= 0L) {
return edges;
}
List<Edge> edgeList = newList();
for (int i = 1; edges.hasNext(); i++) {
Edge edge = edges.next();
if (i <= degree) {
edgeList.add(edge);
}
if (i >= skipDegree) {
return QueryResults.emptyIterator();
}
}
return edgeList.iterator();
}
protected static Set<Id> newIdSet() {
return collectionFactory.newIdSet();
}
protected static <V> Set<V> newSet() {
return newSet(false);
}
protected static <V> Set<V> newSet(boolean concurrent) {
if (concurrent) {
return ConcurrentHashMap.newKeySet();
} else {
return collectionFactory.newSet();
}
}
protected static <V> Set<V> newSet(int initialCapacity) {
return collectionFactory.newSet(initialCapacity);
}
protected static <V> Set<V> newSet(Collection<V> collection) {
return collectionFactory.newSet(collection);
}
protected static <V> List<V> newList() {
return collectionFactory.newList();
}
protected static <V> List<V> newList(int initialCapacity) {
return collectionFactory.newList(initialCapacity);
}
protected static <V> List<V> newList(Collection<V> collection) {
return collectionFactory.newList(collection);
}
protected static <K, V> Map<K, V> newMap() {
return collectionFactory.newMap();
}
protected static <K, V> Map<K, V> newMap(int initialCapacity) {
return collectionFactory.newMap(initialCapacity);
}
protected static <K, V> MultivaluedMap<K, V> newMultivalueMap() {
return new MultivaluedHashMap<>();
}
protected static List<Id> joinPath(Node prev, Node back, boolean ring) {
// Get self path
List<Id> path = prev.path();
// Get reversed other path
List<Id> backPath = back.path();
Collections.reverse(backPath);
if (!ring) {
// Avoid loop in path
if (CollectionUtils.containsAny(path, backPath)) {
return ImmutableList.of();
}
}
// Append other path behind self path
path.addAll(backPath);
return path;
}
public static List<HugeEdge> pathEdges(Iterator<Edge> iterator, HugeEdge edge) {
List<HugeEdge> edges = new ArrayList<>();
if (iterator instanceof NestedIterator) {
edges = ((NestedIterator) iterator).pathEdges();
}
edges.add(edge);
return edges;
}
public HugeGraph graph() {
return this.graph;
}
protected int concurrentDepth() {
return this.graph.option(CoreOptions.OLTP_CONCURRENT_DEPTH);
}
private CollectionType collectionType() {
return this.graph.option(CoreOptions.OLTP_COLLECTION_TYPE);
}
protected Set<Id> adjacentVertices(Id sourceV, Set<Id> vertices,
Directions dir, Id label,
Set<Id> excluded, long degree,
long limit) {
if (limit == 0) {
return ImmutableSet.of();
}
Set<Id> neighbors = newIdSet();
for (Id source : vertices) {
Iterator<Edge> edges = this.edgesOfVertex(source, dir,
label, degree);
while (edges.hasNext()) {
HugeEdge e = (HugeEdge) edges.next();
Id target = e.id().otherVertexId();
boolean matchExcluded = (excluded != null &&
excluded.contains(target));
if (matchExcluded || neighbors.contains(target) ||
sourceV.equals(target)) {
continue;
}
neighbors.add(target);
if (limit != NO_LIMIT && neighbors.size() >= limit) {
return neighbors;
}
}
}
return neighbors;
}
protected Iterator<Id> adjacentVertices(Id source, Directions dir,
Id label, long limit) {
Iterator<Edge> edges = this.edgesOfVertex(source, dir, label, limit);
return new MapperIterator<>(edges, e -> {
HugeEdge edge = (HugeEdge) e;
return edge.id().otherVertexId();
});
}
protected Set<Id> adjacentVertices(Id source, EdgeStep step) {
Set<Id> neighbors = newSet();
Iterator<Edge> edges = this.edgesOfVertex(source, step);
while (edges.hasNext()) {
neighbors.add(((HugeEdge) edges.next()).id().otherVertexId());
}
return neighbors;
}
protected Iterator<Id> adjacentVertices(Id source, Directions dir,
List<Id> labels, long limit) {
Iterator<Edge> edges = this.edgesOfVertex(source, dir, labels, limit);
return new MapperIterator<>(edges, e -> {
HugeEdge edge = (HugeEdge) e;
return edge.id().otherVertexId();
});
}
@Watched
protected Iterator<Edge> edgesOfVertex(Id source, Directions dir,
Id label, long limit) {
Id[] labels = {};
if (label != null) {
labels = new Id[]{label};
}
Query query = GraphTransaction.constructEdgesQuery(source, dir, labels);
if (limit != NO_LIMIT) {
query.limit(limit);
}
return this.graph.edges(query);
}
@Watched
protected Iterator<Edge> edgesOfVertex(Id source, Directions dir,
Map<Id, String> labels, long limit) {
if (labels == null || labels.isEmpty()) {
return this.edgesOfVertex(source, dir, (Id) null, limit);
}
ExtendableIterator<Edge> results = new ExtendableIterator<>();
for (Id label : labels.keySet()) {
E.checkNotNull(label, "edge label");
results.extend(this.edgesOfVertex(source, dir, label, limit));
}
if (limit == NO_LIMIT) {
return results;
}
long[] count = new long[1];
return new LimitIterator<>(results, e -> count[0]++ >= limit);
}
protected Iterator<Edge> edgesOfVertex(Id source, Directions dir,
List<Id> labels, long limit) {
if (labels == null || labels.isEmpty()) {
return this.edgesOfVertex(source, dir, (Id) null, limit);
}
ExtendableIterator<Edge> results = new ExtendableIterator<>();
for (Id label : labels) {
E.checkNotNull(label, "edge label");
results.extend(this.edgesOfVertex(source, dir, label, limit));
}
if (limit == NO_LIMIT) {
return results;
}
long[] count = new long[1];
return new LimitIterator<>(results, e -> count[0]++ >= limit);
}
protected Iterator<Edge> edgesOfVertex(Id source, EdgeStep edgeStep) {
if (edgeStep.properties() == null || edgeStep.properties().isEmpty()) {
Iterator<Edge> edges = this.edgesOfVertex(source,
edgeStep.direction(),
edgeStep.labels(),
edgeStep.limit());
return edgeStep.skipSuperNodeIfNeeded(edges);
}
return this.edgesOfVertex(source, edgeStep, false);
}
protected Iterator<Edge> edgesOfVertexWithSK(Id source, EdgeStep edgeStep) {
assert edgeStep.properties() != null && !edgeStep.properties().isEmpty();
return this.edgesOfVertex(source, edgeStep, true);
}
private Iterator<Edge> edgesOfVertex(Id source, EdgeStep edgeStep,
boolean mustAllSK) {
Id[] edgeLabels = edgeStep.edgeLabels();
Query query = GraphTransaction.constructEdgesQuery(source,
edgeStep.direction(),
edgeLabels);
ConditionQuery filter = null;
if (mustAllSK) {
this.fillFilterBySortKeys(query, edgeLabels, edgeStep.properties());
} else {
filter = (ConditionQuery) query.copy();
this.fillFilterByProperties(filter, edgeStep.properties());
}
query.capacity(Query.NO_CAPACITY);
if (edgeStep.limit() != NO_LIMIT) {
query.limit(edgeStep.limit());
}
Iterator<Edge> edges = this.graph().edges(query);
if (filter != null) {
ConditionQuery finalFilter = filter;
edges = new FilterIterator<>(edges, (e) -> {
return finalFilter.test((HugeEdge) e);
});
}
return edgeStep.skipSuperNodeIfNeeded(edges);
}
public EdgesIterator edgesOfVertices(Iterator<Id> sources,
Directions dir,
List<Id> labelIds,
long degree) {
return new EdgesIterator(new EdgesQueryIterator(sources, dir, labelIds, degree));
}
public Iterator<Edge> edgesOfVertex(Id source, Steps steps) {
List<Id> edgeLabels = steps.edgeLabels();
ConditionQuery cq = GraphTransaction.constructEdgesQuery(
source, steps.direction(), edgeLabels.toArray(new Id[0]));
cq.capacity(Query.NO_CAPACITY);
if (steps.limit() != NO_LIMIT) {
cq.limit(steps.limit());
}
if (steps.isEdgeEmpty()) {
Iterator<Edge> edges = this.graph().edges(cq);
return edgesOfVertexStep(edges, steps);
}
Map<Id, ConditionQuery> edgeConditions =
getFilterQueryConditions(steps.edgeSteps(), HugeType.EDGE);
Iterator<Edge> filteredEdges =
new FilterIterator<>(this.graph().edges(cq),
edge -> validateEdge(edgeConditions, (HugeEdge) edge));
return edgesOfVertexStep(filteredEdges, steps);
}
protected Iterator<Edge> edgesOfVertexStep(Iterator<Edge> edges, Steps steps) {
if (steps.isVertexEmpty()) {
return edges;
}
Map<Id, ConditionQuery> vertexConditions =
getFilterQueryConditions(steps.vertexSteps(), HugeType.VERTEX);
return new FilterIterator<>(edges,
edge -> validateVertex(vertexConditions, (HugeEdge) edge));
}
private Boolean validateVertex(Map<Id, ConditionQuery> conditions,
HugeEdge edge) {
HugeVertex sourceV = edge.sourceVertex();
HugeVertex targetV = edge.targetVertex();
if (!conditions.containsKey(sourceV.schemaLabel().id()) ||
!conditions.containsKey(targetV.schemaLabel().id())) {
return false;
}
ConditionQuery cq = conditions.get(sourceV.schemaLabel().id());
if (cq != null) {
sourceV = (HugeVertex) this.graph.vertex(sourceV.id());
if (!cq.test(sourceV)) {
return false;
}
}
cq = conditions.get(targetV.schemaLabel().id());
if (cq != null) {
targetV = (HugeVertex) this.graph.vertex(targetV.id());
return cq.test(targetV);
}
return true;
}
private Boolean validateEdge(Map<Id, ConditionQuery> conditions,
HugeEdge edge) {
if (!conditions.containsKey(edge.schemaLabel().id())) {
return false;
}
ConditionQuery cq = conditions.get(edge.schemaLabel().id());
if (cq != null) {
return cq.test(edge);
}
return true;
}
private Map<Id, ConditionQuery> getFilterQueryConditions(
Map<Id, Steps.StepEntity> idStepEntityMap, HugeType type) {
Map<Id, ConditionQuery> conditions = new HashMap<>();
for (Map.Entry<Id, Steps.StepEntity> entry : idStepEntityMap.entrySet()) {
Steps.StepEntity stepEntity = entry.getValue();
if (stepEntity.properties() != null && !stepEntity.properties().isEmpty()) {
ConditionQuery cq = new ConditionQuery(type);
Map<Id, Object> properties = stepEntity.properties();
TraversalUtil.fillConditionQuery(cq, properties, this.graph);
conditions.put(entry.getKey(), cq);
} else {
conditions.put(entry.getKey(), null);
}
}
return conditions;
}
private void fillFilterBySortKeys(Query query, Id[] edgeLabels,
Map<Id, Object> properties) {
if (properties == null || properties.isEmpty()) {
return;
}
E.checkArgument(edgeLabels.length == 1,
"The properties filter condition can be set " +
"only if just set one edge label");
this.fillFilterByProperties(query, properties);
ConditionQuery condQuery = (ConditionQuery) query;
if (!GraphTransaction.matchFullEdgeSortKeys(condQuery, this.graph())) {
Id label = condQuery.condition(HugeKeys.LABEL);
E.checkArgument(false, "The properties %s does not match " +
"sort keys of edge label '%s'",
this.graph().mapPkId2Name(properties.keySet()),
this.graph().edgeLabel(label).name());
}
}
private void fillFilterByProperties(Query query,
Map<Id, Object> properties) {
if (properties == null || properties.isEmpty()) {
return;
}
ConditionQuery condQuery = (ConditionQuery) query;
TraversalUtil.fillConditionQuery(condQuery, properties, this.graph);
}
protected long edgesCount(Id source, EdgeStep edgeStep) {
Id[] edgeLabels = edgeStep.edgeLabels();
Query query = GraphTransaction.constructEdgesQuery(source,
edgeStep.direction(),
edgeLabels);
this.fillFilterBySortKeys(query, edgeLabels, edgeStep.properties());
query.aggregate(Aggregate.AggregateFunc.COUNT, null);
query.capacity(Query.NO_CAPACITY);
query.limit(Query.NO_LIMIT);
long count = graph().queryNumber(query).longValue();
if (edgeStep.degree() == NO_LIMIT || count < edgeStep.degree()) {
return count;
} else if (edgeStep.skipDegree() != 0L &&
count >= edgeStep.skipDegree()) {
return 0L;
} else {
return edgeStep.degree();
}
}
protected Object getVertexLabelIdOrNull(Object label) {
if (label == null) {
return null;
}
return SchemaLabel.getVertexLabelId(this.graph, label);
}
protected Id getEdgeLabelIdOrNull(Object label) {
if (label == null) {
return null;
}
return SchemaLabel.getEdgeLabelId(this.graph, label);
}
protected void checkVertexExist(Id vertexId, String name) {
try {
this.graph.vertex(vertexId);
} catch (NotFoundException e) {
throw new IllegalArgumentException(String.format(
"The %s with id '%s' does not exist", name, vertexId), e);
}
}
public Iterator<Edge> createNestedIterator(Id sourceV, Steps steps,
int depth, Set<Id> visited, boolean nearest) {
E.checkArgument(depth > 0, "The depth should large than 0 for nested iterator");
visited.add(sourceV);
// build a chained iterator path with length of depth
Iterator<Edge> iterator = this.edgesOfVertex(sourceV, steps);
for (int i = 1; i < depth; i++) {
iterator = new NestedIterator(this, iterator, steps, visited, nearest);
}
return iterator;
}
public static class Node {
private final Id id;
private final Node parent;
public Node(Id id) {
this(id, null);
}
public Node(Id id, Node parent) {
E.checkArgumentNotNull(id, "Id of Node can't be null");
this.id = id;
this.parent = parent;
}
public Id id() {
return this.id;
}
public Node parent() {
return this.parent;
}
public List<Id> path() {
List<Id> ids = newList();
Node current = this;
do {
ids.add(current.id);
current = current.parent;
} while (current != null);
Collections.reverse(ids);
return ids;
}
public List<Id> joinPath(Node back) {
return HugeTraverser.joinPath(this, back, false);
}
public boolean contains(Id id) {
Node node = this;
do {
if (node.id.equals(id)) {
return true;
}
node = node.parent;
} while (node != null);
return false;
}
@Override
public int hashCode() {
return this.id.hashCode();
}
@Override
public boolean equals(Object object) {
if (!(object instanceof Node)) {
return false;
}
Node other = (Node) object;
return Objects.equals(this.id, other.id) &&
Objects.equals(this.parent, other.parent);
}
@Override
public String toString() {
return this.id.toString();
}
}
public static class Path {
public static final Path EMPTY = new Path(ImmutableList.of());
private final Id crosspoint;
private final List<Id> vertices;
private Set<Edge> edges = Collections.emptySet();
public Path(List<Id> vertices) {
this(null, vertices);
}
public Path(Id crosspoint, List<Id> vertices) {
this.crosspoint = crosspoint;
this.vertices = vertices;
}
public Path(List<Id> vertices, Set<Edge> edges) {
this(null, vertices);
this.edges = edges;
}
public Set<Edge> getEdges() {
return edges;
}
public void setEdges(Set<Edge> edges) {
this.edges = edges;
}
public Id crosspoint() {
return this.crosspoint;
}
public void addToLast(Id id) {
this.vertices.add(id);
}
public List<Id> vertices() {
return this.vertices;
}
public void reverse() {
Collections.reverse(this.vertices);
}
public Map<String, Object> toMap(boolean withCrossPoint) {
if (withCrossPoint) {
return ImmutableMap.of("crosspoint", this.crosspoint,
"objects", this.vertices);
} else {
return ImmutableMap.of("objects", this.vertices);
}
}
public boolean ownedBy(Id source) {
E.checkNotNull(source, "source");
Id min = null;
for (Id id : this.vertices) {
if (min == null || id.compareTo(min) < 0) {
min = id;
}
}
return source.equals(min);
}
@Override
public int hashCode() {
return this.vertices.hashCode();
}
/**
* Compares the specified object with this path for equality.
* Returns <tt>true</tt> if and only if both have same vertices list
* without regard of crosspoint.
*
* @param other the object to be compared for equality with this path
* @return <tt>true</tt> if the specified object is equal to this path
*/
@Override
public boolean equals(Object other) {
if (!(other instanceof Path)) {
return false;
}
return this.vertices.equals(((Path) other).vertices);
}
@Override
public String toString() {
return this.vertices.toString();
}
}
public static class PathSet implements Set<Path> {
public static final PathSet EMPTY = new PathSet(ImmutableSet.of());
private final Set<Path> paths;
private Set<Edge> edges = Collections.emptySet();
public PathSet(Set<Path> paths, Set<Edge> edges) {
this(paths);
this.edges = edges;
}
public PathSet() {
this(newSet());
}
private PathSet(Set<Path> paths) {
this.paths = paths;
}
public Set<Path> getPaths() {
return this.paths;
}
public Set<Edge> getEdges() {
return edges;
}
public void setEdges(Set<Edge> edges) {
this.edges = edges;
}
@Override
public boolean add(Path path) {
return this.paths.add(path);
}
@Override
public boolean remove(Object o) {
return this.paths.remove(o);
}
@Override
public boolean containsAll(Collection<?> c) {
return this.paths.containsAll(c);
}
@Override
public boolean addAll(Collection<? extends Path> c) {
return this.paths.addAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return this.paths.retainAll(c);
}
@Override
public boolean removeAll(Collection<?> c) {
return this.paths.removeAll(c);
}
@Override
public void clear() {
this.paths.clear();
}
@Override
public boolean isEmpty() {
return this.paths.isEmpty();
}
@Override
public boolean contains(Object o) {
return this.paths.contains(o);
}
@Override
public int size() {
return this.paths.size();
}
@Override
public Iterator<Path> iterator() {
return this.paths.iterator();
}
@Override
public Object[] toArray() {
return this.paths.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return this.paths.toArray(a);
}
public boolean addAll(PathSet paths) {
return this.paths.addAll(paths.paths);
}
public Set<Id> vertices() {
Set<Id> vertices = newIdSet();
for (Path path : this.paths) {
vertices.addAll(path.vertices());
}
return vertices;
}
@Override
public String toString() {
return this.paths.toString();
}
public void append(Id current) {
for (Iterator<Path> iter = paths.iterator(); iter.hasNext(); ) {
Path path = iter.next();
if (path.vertices().contains(current)) {
iter.remove();
continue;
}
path.addToLast(current);
}
}
}
public static class EdgeRecord {
private final Map<Long, Edge> edgeMap;
private final ObjectIntMapping<Id> idMapping;
public EdgeRecord(boolean concurrent) {
this.edgeMap = new HashMap<>();
this.idMapping = ObjectIntMappingFactory.newObjectIntMapping(concurrent);
}
private static Long makeVertexPairIndex(int source, int target) {
return ((long) source & 0xFFFFFFFFL) |
(((long) target << 32) & 0xFFFFFFFF00000000L);
}
public static Set<Id> getEdgeIds(Set<Edge> edges) {
return edges.stream().map(edge -> ((HugeEdge) edge).id()).collect(Collectors.toSet());
}
private int code(Id id) {
if (id.number()) {
long l = id.asLong();
if (0 <= l && l <= Integer.MAX_VALUE) {
return (int) l;
}
}
int code = this.idMapping.object2Code(id);
assert code > 0;
return -code;
}
public void addEdge(Id source, Id target, Edge edge) {
Long index = makeVertexPairIndex(this.code(source), this.code(target));
this.edgeMap.put(index, edge);
}
private Edge getEdge(Id source, Id target) {
Long index = makeVertexPairIndex(this.code(source), this.code(target));
return this.edgeMap.get(index);
}
public Set<Edge> getEdges(HugeTraverser.Path path) {
if (path == null || path.vertices().isEmpty()) {
return new HashSet<>();
}
Iterator<Id> vertexIter = path.vertices().iterator();
return getEdges(vertexIter);
}
public Set<Edge> getEdges(Collection<HugeTraverser.Path> paths) {
Set<Edge> edgeIds = new HashSet<>();
for (HugeTraverser.Path path : paths) {
edgeIds.addAll(getEdges(path));
}
return edgeIds;
}
public Set<Edge> getEdges(Iterator<Id> vertexIter) {
Set<Edge> edges = new HashSet<>();
Id first = vertexIter.next();
Id second;
while (vertexIter.hasNext()) {
second = vertexIter.next();
Edge edge = getEdge(first, second);
if (edge == null) {
edge = getEdge(second, first);
}
if (edge != null) {
edges.add(edge);
}
first = second;
}
return edges;
}
}
public class EdgesIterator implements Iterator<Iterator<Edge>>, Closeable {
private final Iterator<Iterator<Edge>> currentIter;
public EdgesIterator(EdgesQueryIterator queries) {
List<Iterator<Edge>> iteratorList = new ArrayList<>();
while (queries.hasNext()) {
Iterator<Edge> edges = graph.edges(queries.next());
iteratorList.add(edges);
}
this.currentIter = iteratorList.iterator();
}
@Override
public boolean hasNext() {
return this.currentIter.hasNext();
}
@Override
public Iterator<Edge> next() {
return this.currentIter.next();
}
@Override
public void close() throws IOException {
CloseableIterator.closeIterator(currentIter);
}
}
}
|
googleads/google-ads-java | 36,481 | google-ads-stubs-v19/src/main/java/com/google/ads/googleads/v19/common/UserListLogicalRuleInfo.java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/ads/googleads/v19/common/user_lists.proto
// Protobuf Java Version: 3.25.7
package com.google.ads.googleads.v19.common;
/**
* <pre>
* A user list logical rule. A rule has a logical operator (and/or/not) and a
* list of user lists as operands.
* </pre>
*
* Protobuf type {@code google.ads.googleads.v19.common.UserListLogicalRuleInfo}
*/
public final class UserListLogicalRuleInfo extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:google.ads.googleads.v19.common.UserListLogicalRuleInfo)
UserListLogicalRuleInfoOrBuilder {
private static final long serialVersionUID = 0L;
// Use UserListLogicalRuleInfo.newBuilder() to construct.
private UserListLogicalRuleInfo(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UserListLogicalRuleInfo() {
operator_ = 0;
ruleOperands_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new UserListLogicalRuleInfo();
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v19.common.UserListsProto.internal_static_google_ads_googleads_v19_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v19.common.UserListsProto.internal_static_google_ads_googleads_v19_common_UserListLogicalRuleInfo_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v19.common.UserListLogicalRuleInfo.class, com.google.ads.googleads.v19.common.UserListLogicalRuleInfo.Builder.class);
}
public static final int OPERATOR_FIELD_NUMBER = 1;
private int operator_ = 0;
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The enum numeric value on the wire for operator.
*/
@java.lang.Override public int getOperatorValue() {
return operator_;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The operator.
*/
@java.lang.Override public com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator getOperator() {
com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator result = com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.forNumber(operator_);
return result == null ? com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNRECOGNIZED : result;
}
public static final int RULE_OPERANDS_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private java.util.List<com.google.ads.googleads.v19.common.LogicalUserListOperandInfo> ruleOperands_;
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public java.util.List<com.google.ads.googleads.v19.common.LogicalUserListOperandInfo> getRuleOperandsList() {
return ruleOperands_;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.ads.googleads.v19.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsOrBuilderList() {
return ruleOperands_;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public int getRuleOperandsCount() {
return ruleOperands_.size();
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public com.google.ads.googleads.v19.common.LogicalUserListOperandInfo getRuleOperands(int index) {
return ruleOperands_.get(index);
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public com.google.ads.googleads.v19.common.LogicalUserListOperandInfoOrBuilder getRuleOperandsOrBuilder(
int index) {
return ruleOperands_.get(index);
}
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 (operator_ != com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNSPECIFIED.getNumber()) {
output.writeEnum(1, operator_);
}
for (int i = 0; i < ruleOperands_.size(); i++) {
output.writeMessage(2, ruleOperands_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (operator_ != com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNSPECIFIED.getNumber()) {
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(1, operator_);
}
for (int i = 0; i < ruleOperands_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(2, ruleOperands_.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.ads.googleads.v19.common.UserListLogicalRuleInfo)) {
return super.equals(obj);
}
com.google.ads.googleads.v19.common.UserListLogicalRuleInfo other = (com.google.ads.googleads.v19.common.UserListLogicalRuleInfo) obj;
if (operator_ != other.operator_) return false;
if (!getRuleOperandsList()
.equals(other.getRuleOperandsList())) 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();
hash = (37 * hash) + OPERATOR_FIELD_NUMBER;
hash = (53 * hash) + operator_;
if (getRuleOperandsCount() > 0) {
hash = (37 * hash) + RULE_OPERANDS_FIELD_NUMBER;
hash = (53 * hash) + getRuleOperandsList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo 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.ads.googleads.v19.common.UserListLogicalRuleInfo parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo 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.ads.googleads.v19.common.UserListLogicalRuleInfo parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo 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.ads.googleads.v19.common.UserListLogicalRuleInfo parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo 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.ads.googleads.v19.common.UserListLogicalRuleInfo 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;
}
/**
* <pre>
* A user list logical rule. A rule has a logical operator (and/or/not) and a
* list of user lists as operands.
* </pre>
*
* Protobuf type {@code google.ads.googleads.v19.common.UserListLogicalRuleInfo}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:google.ads.googleads.v19.common.UserListLogicalRuleInfo)
com.google.ads.googleads.v19.common.UserListLogicalRuleInfoOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v19.common.UserListsProto.internal_static_google_ads_googleads_v19_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v19.common.UserListsProto.internal_static_google_ads_googleads_v19_common_UserListLogicalRuleInfo_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v19.common.UserListLogicalRuleInfo.class, com.google.ads.googleads.v19.common.UserListLogicalRuleInfo.Builder.class);
}
// Construct using com.google.ads.googleads.v19.common.UserListLogicalRuleInfo.newBuilder()
private Builder() {
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
operator_ = 0;
if (ruleOperandsBuilder_ == null) {
ruleOperands_ = java.util.Collections.emptyList();
} else {
ruleOperands_ = null;
ruleOperandsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000002);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return com.google.ads.googleads.v19.common.UserListsProto.internal_static_google_ads_googleads_v19_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
public com.google.ads.googleads.v19.common.UserListLogicalRuleInfo getDefaultInstanceForType() {
return com.google.ads.googleads.v19.common.UserListLogicalRuleInfo.getDefaultInstance();
}
@java.lang.Override
public com.google.ads.googleads.v19.common.UserListLogicalRuleInfo build() {
com.google.ads.googleads.v19.common.UserListLogicalRuleInfo result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.ads.googleads.v19.common.UserListLogicalRuleInfo buildPartial() {
com.google.ads.googleads.v19.common.UserListLogicalRuleInfo result = new com.google.ads.googleads.v19.common.UserListLogicalRuleInfo(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartialRepeatedFields(com.google.ads.googleads.v19.common.UserListLogicalRuleInfo result) {
if (ruleOperandsBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)) {
ruleOperands_ = java.util.Collections.unmodifiableList(ruleOperands_);
bitField0_ = (bitField0_ & ~0x00000002);
}
result.ruleOperands_ = ruleOperands_;
} else {
result.ruleOperands_ = ruleOperandsBuilder_.build();
}
}
private void buildPartial0(com.google.ads.googleads.v19.common.UserListLogicalRuleInfo result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.operator_ = operator_;
}
}
@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.ads.googleads.v19.common.UserListLogicalRuleInfo) {
return mergeFrom((com.google.ads.googleads.v19.common.UserListLogicalRuleInfo)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.ads.googleads.v19.common.UserListLogicalRuleInfo other) {
if (other == com.google.ads.googleads.v19.common.UserListLogicalRuleInfo.getDefaultInstance()) return this;
if (other.operator_ != 0) {
setOperatorValue(other.getOperatorValue());
}
if (ruleOperandsBuilder_ == null) {
if (!other.ruleOperands_.isEmpty()) {
if (ruleOperands_.isEmpty()) {
ruleOperands_ = other.ruleOperands_;
bitField0_ = (bitField0_ & ~0x00000002);
} else {
ensureRuleOperandsIsMutable();
ruleOperands_.addAll(other.ruleOperands_);
}
onChanged();
}
} else {
if (!other.ruleOperands_.isEmpty()) {
if (ruleOperandsBuilder_.isEmpty()) {
ruleOperandsBuilder_.dispose();
ruleOperandsBuilder_ = null;
ruleOperands_ = other.ruleOperands_;
bitField0_ = (bitField0_ & ~0x00000002);
ruleOperandsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
getRuleOperandsFieldBuilder() : null;
} else {
ruleOperandsBuilder_.addAllMessages(other.ruleOperands_);
}
}
}
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 8: {
operator_ = input.readEnum();
bitField0_ |= 0x00000001;
break;
} // case 8
case 18: {
com.google.ads.googleads.v19.common.LogicalUserListOperandInfo m =
input.readMessage(
com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.parser(),
extensionRegistry);
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(m);
} else {
ruleOperandsBuilder_.addMessage(m);
}
break;
} // case 18
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 int operator_ = 0;
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The enum numeric value on the wire for operator.
*/
@java.lang.Override public int getOperatorValue() {
return operator_;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @param value The enum numeric value on the wire for operator to set.
* @return This builder for chaining.
*/
public Builder setOperatorValue(int value) {
operator_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The operator.
*/
@java.lang.Override
public com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator getOperator() {
com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator result = com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.forNumber(operator_);
return result == null ? com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNRECOGNIZED : result;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @param value The operator to set.
* @return This builder for chaining.
*/
public Builder setOperator(com.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000001;
operator_ = value.getNumber();
onChanged();
return this;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v19.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return This builder for chaining.
*/
public Builder clearOperator() {
bitField0_ = (bitField0_ & ~0x00000001);
operator_ = 0;
onChanged();
return this;
}
private java.util.List<com.google.ads.googleads.v19.common.LogicalUserListOperandInfo> ruleOperands_ =
java.util.Collections.emptyList();
private void ensureRuleOperandsIsMutable() {
if (!((bitField0_ & 0x00000002) != 0)) {
ruleOperands_ = new java.util.ArrayList<com.google.ads.googleads.v19.common.LogicalUserListOperandInfo>(ruleOperands_);
bitField0_ |= 0x00000002;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v19.common.LogicalUserListOperandInfo, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v19.common.LogicalUserListOperandInfoOrBuilder> ruleOperandsBuilder_;
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<com.google.ads.googleads.v19.common.LogicalUserListOperandInfo> getRuleOperandsList() {
if (ruleOperandsBuilder_ == null) {
return java.util.Collections.unmodifiableList(ruleOperands_);
} else {
return ruleOperandsBuilder_.getMessageList();
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public int getRuleOperandsCount() {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.size();
} else {
return ruleOperandsBuilder_.getCount();
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v19.common.LogicalUserListOperandInfo getRuleOperands(int index) {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.get(index);
} else {
return ruleOperandsBuilder_.getMessage(index);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder setRuleOperands(
int index, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.set(index, value);
onChanged();
} else {
ruleOperandsBuilder_.setMessage(index, value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder setRuleOperands(
int index, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.set(index, builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(com.google.ads.googleads.v19.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.add(value);
onChanged();
} else {
ruleOperandsBuilder_.addMessage(value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
int index, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.add(index, value);
onChanged();
} else {
ruleOperandsBuilder_.addMessage(index, value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
int index, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(index, builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addAllRuleOperands(
java.lang.Iterable<? extends com.google.ads.googleads.v19.common.LogicalUserListOperandInfo> values) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
values, ruleOperands_);
onChanged();
} else {
ruleOperandsBuilder_.addAllMessages(values);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder clearRuleOperands() {
if (ruleOperandsBuilder_ == null) {
ruleOperands_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
} else {
ruleOperandsBuilder_.clear();
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder removeRuleOperands(int index) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.remove(index);
onChanged();
} else {
ruleOperandsBuilder_.remove(index);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder getRuleOperandsBuilder(
int index) {
return getRuleOperandsFieldBuilder().getBuilder(index);
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v19.common.LogicalUserListOperandInfoOrBuilder getRuleOperandsOrBuilder(
int index) {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.get(index); } else {
return ruleOperandsBuilder_.getMessageOrBuilder(index);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<? extends com.google.ads.googleads.v19.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsOrBuilderList() {
if (ruleOperandsBuilder_ != null) {
return ruleOperandsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(ruleOperands_);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder addRuleOperandsBuilder() {
return getRuleOperandsFieldBuilder().addBuilder(
com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.getDefaultInstance());
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder addRuleOperandsBuilder(
int index) {
return getRuleOperandsFieldBuilder().addBuilder(
index, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.getDefaultInstance());
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v19.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder>
getRuleOperandsBuilderList() {
return getRuleOperandsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v19.common.LogicalUserListOperandInfo, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v19.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsFieldBuilder() {
if (ruleOperandsBuilder_ == null) {
ruleOperandsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v19.common.LogicalUserListOperandInfo, com.google.ads.googleads.v19.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v19.common.LogicalUserListOperandInfoOrBuilder>(
ruleOperands_,
((bitField0_ & 0x00000002) != 0),
getParentForChildren(),
isClean());
ruleOperands_ = null;
}
return ruleOperandsBuilder_;
}
@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.ads.googleads.v19.common.UserListLogicalRuleInfo)
}
// @@protoc_insertion_point(class_scope:google.ads.googleads.v19.common.UserListLogicalRuleInfo)
private static final com.google.ads.googleads.v19.common.UserListLogicalRuleInfo DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.ads.googleads.v19.common.UserListLogicalRuleInfo();
}
public static com.google.ads.googleads.v19.common.UserListLogicalRuleInfo getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UserListLogicalRuleInfo>
PARSER = new com.google.protobuf.AbstractParser<UserListLogicalRuleInfo>() {
@java.lang.Override
public UserListLogicalRuleInfo 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<UserListLogicalRuleInfo> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UserListLogicalRuleInfo> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.ads.googleads.v19.common.UserListLogicalRuleInfo getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleads/google-ads-java | 36,481 | google-ads-stubs-v20/src/main/java/com/google/ads/googleads/v20/common/UserListLogicalRuleInfo.java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/ads/googleads/v20/common/user_lists.proto
// Protobuf Java Version: 3.25.7
package com.google.ads.googleads.v20.common;
/**
* <pre>
* A user list logical rule. A rule has a logical operator (and/or/not) and a
* list of user lists as operands.
* </pre>
*
* Protobuf type {@code google.ads.googleads.v20.common.UserListLogicalRuleInfo}
*/
public final class UserListLogicalRuleInfo extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:google.ads.googleads.v20.common.UserListLogicalRuleInfo)
UserListLogicalRuleInfoOrBuilder {
private static final long serialVersionUID = 0L;
// Use UserListLogicalRuleInfo.newBuilder() to construct.
private UserListLogicalRuleInfo(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UserListLogicalRuleInfo() {
operator_ = 0;
ruleOperands_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new UserListLogicalRuleInfo();
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v20.common.UserListsProto.internal_static_google_ads_googleads_v20_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v20.common.UserListsProto.internal_static_google_ads_googleads_v20_common_UserListLogicalRuleInfo_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v20.common.UserListLogicalRuleInfo.class, com.google.ads.googleads.v20.common.UserListLogicalRuleInfo.Builder.class);
}
public static final int OPERATOR_FIELD_NUMBER = 1;
private int operator_ = 0;
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The enum numeric value on the wire for operator.
*/
@java.lang.Override public int getOperatorValue() {
return operator_;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The operator.
*/
@java.lang.Override public com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator getOperator() {
com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator result = com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.forNumber(operator_);
return result == null ? com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNRECOGNIZED : result;
}
public static final int RULE_OPERANDS_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private java.util.List<com.google.ads.googleads.v20.common.LogicalUserListOperandInfo> ruleOperands_;
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public java.util.List<com.google.ads.googleads.v20.common.LogicalUserListOperandInfo> getRuleOperandsList() {
return ruleOperands_;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.ads.googleads.v20.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsOrBuilderList() {
return ruleOperands_;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public int getRuleOperandsCount() {
return ruleOperands_.size();
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public com.google.ads.googleads.v20.common.LogicalUserListOperandInfo getRuleOperands(int index) {
return ruleOperands_.get(index);
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public com.google.ads.googleads.v20.common.LogicalUserListOperandInfoOrBuilder getRuleOperandsOrBuilder(
int index) {
return ruleOperands_.get(index);
}
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 (operator_ != com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNSPECIFIED.getNumber()) {
output.writeEnum(1, operator_);
}
for (int i = 0; i < ruleOperands_.size(); i++) {
output.writeMessage(2, ruleOperands_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (operator_ != com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNSPECIFIED.getNumber()) {
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(1, operator_);
}
for (int i = 0; i < ruleOperands_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(2, ruleOperands_.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.ads.googleads.v20.common.UserListLogicalRuleInfo)) {
return super.equals(obj);
}
com.google.ads.googleads.v20.common.UserListLogicalRuleInfo other = (com.google.ads.googleads.v20.common.UserListLogicalRuleInfo) obj;
if (operator_ != other.operator_) return false;
if (!getRuleOperandsList()
.equals(other.getRuleOperandsList())) 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();
hash = (37 * hash) + OPERATOR_FIELD_NUMBER;
hash = (53 * hash) + operator_;
if (getRuleOperandsCount() > 0) {
hash = (37 * hash) + RULE_OPERANDS_FIELD_NUMBER;
hash = (53 * hash) + getRuleOperandsList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo 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.ads.googleads.v20.common.UserListLogicalRuleInfo parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo 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.ads.googleads.v20.common.UserListLogicalRuleInfo parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo 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.ads.googleads.v20.common.UserListLogicalRuleInfo parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo 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.ads.googleads.v20.common.UserListLogicalRuleInfo 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;
}
/**
* <pre>
* A user list logical rule. A rule has a logical operator (and/or/not) and a
* list of user lists as operands.
* </pre>
*
* Protobuf type {@code google.ads.googleads.v20.common.UserListLogicalRuleInfo}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:google.ads.googleads.v20.common.UserListLogicalRuleInfo)
com.google.ads.googleads.v20.common.UserListLogicalRuleInfoOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v20.common.UserListsProto.internal_static_google_ads_googleads_v20_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v20.common.UserListsProto.internal_static_google_ads_googleads_v20_common_UserListLogicalRuleInfo_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v20.common.UserListLogicalRuleInfo.class, com.google.ads.googleads.v20.common.UserListLogicalRuleInfo.Builder.class);
}
// Construct using com.google.ads.googleads.v20.common.UserListLogicalRuleInfo.newBuilder()
private Builder() {
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
operator_ = 0;
if (ruleOperandsBuilder_ == null) {
ruleOperands_ = java.util.Collections.emptyList();
} else {
ruleOperands_ = null;
ruleOperandsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000002);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return com.google.ads.googleads.v20.common.UserListsProto.internal_static_google_ads_googleads_v20_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
public com.google.ads.googleads.v20.common.UserListLogicalRuleInfo getDefaultInstanceForType() {
return com.google.ads.googleads.v20.common.UserListLogicalRuleInfo.getDefaultInstance();
}
@java.lang.Override
public com.google.ads.googleads.v20.common.UserListLogicalRuleInfo build() {
com.google.ads.googleads.v20.common.UserListLogicalRuleInfo result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.ads.googleads.v20.common.UserListLogicalRuleInfo buildPartial() {
com.google.ads.googleads.v20.common.UserListLogicalRuleInfo result = new com.google.ads.googleads.v20.common.UserListLogicalRuleInfo(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartialRepeatedFields(com.google.ads.googleads.v20.common.UserListLogicalRuleInfo result) {
if (ruleOperandsBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)) {
ruleOperands_ = java.util.Collections.unmodifiableList(ruleOperands_);
bitField0_ = (bitField0_ & ~0x00000002);
}
result.ruleOperands_ = ruleOperands_;
} else {
result.ruleOperands_ = ruleOperandsBuilder_.build();
}
}
private void buildPartial0(com.google.ads.googleads.v20.common.UserListLogicalRuleInfo result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.operator_ = operator_;
}
}
@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.ads.googleads.v20.common.UserListLogicalRuleInfo) {
return mergeFrom((com.google.ads.googleads.v20.common.UserListLogicalRuleInfo)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.ads.googleads.v20.common.UserListLogicalRuleInfo other) {
if (other == com.google.ads.googleads.v20.common.UserListLogicalRuleInfo.getDefaultInstance()) return this;
if (other.operator_ != 0) {
setOperatorValue(other.getOperatorValue());
}
if (ruleOperandsBuilder_ == null) {
if (!other.ruleOperands_.isEmpty()) {
if (ruleOperands_.isEmpty()) {
ruleOperands_ = other.ruleOperands_;
bitField0_ = (bitField0_ & ~0x00000002);
} else {
ensureRuleOperandsIsMutable();
ruleOperands_.addAll(other.ruleOperands_);
}
onChanged();
}
} else {
if (!other.ruleOperands_.isEmpty()) {
if (ruleOperandsBuilder_.isEmpty()) {
ruleOperandsBuilder_.dispose();
ruleOperandsBuilder_ = null;
ruleOperands_ = other.ruleOperands_;
bitField0_ = (bitField0_ & ~0x00000002);
ruleOperandsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
getRuleOperandsFieldBuilder() : null;
} else {
ruleOperandsBuilder_.addAllMessages(other.ruleOperands_);
}
}
}
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 8: {
operator_ = input.readEnum();
bitField0_ |= 0x00000001;
break;
} // case 8
case 18: {
com.google.ads.googleads.v20.common.LogicalUserListOperandInfo m =
input.readMessage(
com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.parser(),
extensionRegistry);
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(m);
} else {
ruleOperandsBuilder_.addMessage(m);
}
break;
} // case 18
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 int operator_ = 0;
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The enum numeric value on the wire for operator.
*/
@java.lang.Override public int getOperatorValue() {
return operator_;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @param value The enum numeric value on the wire for operator to set.
* @return This builder for chaining.
*/
public Builder setOperatorValue(int value) {
operator_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The operator.
*/
@java.lang.Override
public com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator getOperator() {
com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator result = com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.forNumber(operator_);
return result == null ? com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNRECOGNIZED : result;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @param value The operator to set.
* @return This builder for chaining.
*/
public Builder setOperator(com.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000001;
operator_ = value.getNumber();
onChanged();
return this;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v20.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return This builder for chaining.
*/
public Builder clearOperator() {
bitField0_ = (bitField0_ & ~0x00000001);
operator_ = 0;
onChanged();
return this;
}
private java.util.List<com.google.ads.googleads.v20.common.LogicalUserListOperandInfo> ruleOperands_ =
java.util.Collections.emptyList();
private void ensureRuleOperandsIsMutable() {
if (!((bitField0_ & 0x00000002) != 0)) {
ruleOperands_ = new java.util.ArrayList<com.google.ads.googleads.v20.common.LogicalUserListOperandInfo>(ruleOperands_);
bitField0_ |= 0x00000002;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v20.common.LogicalUserListOperandInfo, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v20.common.LogicalUserListOperandInfoOrBuilder> ruleOperandsBuilder_;
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<com.google.ads.googleads.v20.common.LogicalUserListOperandInfo> getRuleOperandsList() {
if (ruleOperandsBuilder_ == null) {
return java.util.Collections.unmodifiableList(ruleOperands_);
} else {
return ruleOperandsBuilder_.getMessageList();
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public int getRuleOperandsCount() {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.size();
} else {
return ruleOperandsBuilder_.getCount();
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v20.common.LogicalUserListOperandInfo getRuleOperands(int index) {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.get(index);
} else {
return ruleOperandsBuilder_.getMessage(index);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder setRuleOperands(
int index, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.set(index, value);
onChanged();
} else {
ruleOperandsBuilder_.setMessage(index, value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder setRuleOperands(
int index, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.set(index, builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(com.google.ads.googleads.v20.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.add(value);
onChanged();
} else {
ruleOperandsBuilder_.addMessage(value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
int index, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.add(index, value);
onChanged();
} else {
ruleOperandsBuilder_.addMessage(index, value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
int index, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(index, builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addAllRuleOperands(
java.lang.Iterable<? extends com.google.ads.googleads.v20.common.LogicalUserListOperandInfo> values) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
values, ruleOperands_);
onChanged();
} else {
ruleOperandsBuilder_.addAllMessages(values);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder clearRuleOperands() {
if (ruleOperandsBuilder_ == null) {
ruleOperands_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
} else {
ruleOperandsBuilder_.clear();
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder removeRuleOperands(int index) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.remove(index);
onChanged();
} else {
ruleOperandsBuilder_.remove(index);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder getRuleOperandsBuilder(
int index) {
return getRuleOperandsFieldBuilder().getBuilder(index);
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v20.common.LogicalUserListOperandInfoOrBuilder getRuleOperandsOrBuilder(
int index) {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.get(index); } else {
return ruleOperandsBuilder_.getMessageOrBuilder(index);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<? extends com.google.ads.googleads.v20.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsOrBuilderList() {
if (ruleOperandsBuilder_ != null) {
return ruleOperandsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(ruleOperands_);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder addRuleOperandsBuilder() {
return getRuleOperandsFieldBuilder().addBuilder(
com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.getDefaultInstance());
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder addRuleOperandsBuilder(
int index) {
return getRuleOperandsFieldBuilder().addBuilder(
index, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.getDefaultInstance());
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v20.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder>
getRuleOperandsBuilderList() {
return getRuleOperandsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v20.common.LogicalUserListOperandInfo, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v20.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsFieldBuilder() {
if (ruleOperandsBuilder_ == null) {
ruleOperandsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v20.common.LogicalUserListOperandInfo, com.google.ads.googleads.v20.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v20.common.LogicalUserListOperandInfoOrBuilder>(
ruleOperands_,
((bitField0_ & 0x00000002) != 0),
getParentForChildren(),
isClean());
ruleOperands_ = null;
}
return ruleOperandsBuilder_;
}
@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.ads.googleads.v20.common.UserListLogicalRuleInfo)
}
// @@protoc_insertion_point(class_scope:google.ads.googleads.v20.common.UserListLogicalRuleInfo)
private static final com.google.ads.googleads.v20.common.UserListLogicalRuleInfo DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.ads.googleads.v20.common.UserListLogicalRuleInfo();
}
public static com.google.ads.googleads.v20.common.UserListLogicalRuleInfo getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UserListLogicalRuleInfo>
PARSER = new com.google.protobuf.AbstractParser<UserListLogicalRuleInfo>() {
@java.lang.Override
public UserListLogicalRuleInfo 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<UserListLogicalRuleInfo> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UserListLogicalRuleInfo> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.ads.googleads.v20.common.UserListLogicalRuleInfo getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleads/google-ads-java | 36,481 | google-ads-stubs-v21/src/main/java/com/google/ads/googleads/v21/common/UserListLogicalRuleInfo.java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/ads/googleads/v21/common/user_lists.proto
// Protobuf Java Version: 3.25.7
package com.google.ads.googleads.v21.common;
/**
* <pre>
* A user list logical rule. A rule has a logical operator (and/or/not) and a
* list of user lists as operands.
* </pre>
*
* Protobuf type {@code google.ads.googleads.v21.common.UserListLogicalRuleInfo}
*/
public final class UserListLogicalRuleInfo extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:google.ads.googleads.v21.common.UserListLogicalRuleInfo)
UserListLogicalRuleInfoOrBuilder {
private static final long serialVersionUID = 0L;
// Use UserListLogicalRuleInfo.newBuilder() to construct.
private UserListLogicalRuleInfo(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UserListLogicalRuleInfo() {
operator_ = 0;
ruleOperands_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new UserListLogicalRuleInfo();
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v21.common.UserListsProto.internal_static_google_ads_googleads_v21_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v21.common.UserListsProto.internal_static_google_ads_googleads_v21_common_UserListLogicalRuleInfo_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v21.common.UserListLogicalRuleInfo.class, com.google.ads.googleads.v21.common.UserListLogicalRuleInfo.Builder.class);
}
public static final int OPERATOR_FIELD_NUMBER = 1;
private int operator_ = 0;
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The enum numeric value on the wire for operator.
*/
@java.lang.Override public int getOperatorValue() {
return operator_;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The operator.
*/
@java.lang.Override public com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator getOperator() {
com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator result = com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.forNumber(operator_);
return result == null ? com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNRECOGNIZED : result;
}
public static final int RULE_OPERANDS_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private java.util.List<com.google.ads.googleads.v21.common.LogicalUserListOperandInfo> ruleOperands_;
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public java.util.List<com.google.ads.googleads.v21.common.LogicalUserListOperandInfo> getRuleOperandsList() {
return ruleOperands_;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.ads.googleads.v21.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsOrBuilderList() {
return ruleOperands_;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public int getRuleOperandsCount() {
return ruleOperands_.size();
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public com.google.ads.googleads.v21.common.LogicalUserListOperandInfo getRuleOperands(int index) {
return ruleOperands_.get(index);
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
@java.lang.Override
public com.google.ads.googleads.v21.common.LogicalUserListOperandInfoOrBuilder getRuleOperandsOrBuilder(
int index) {
return ruleOperands_.get(index);
}
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 (operator_ != com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNSPECIFIED.getNumber()) {
output.writeEnum(1, operator_);
}
for (int i = 0; i < ruleOperands_.size(); i++) {
output.writeMessage(2, ruleOperands_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (operator_ != com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNSPECIFIED.getNumber()) {
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(1, operator_);
}
for (int i = 0; i < ruleOperands_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(2, ruleOperands_.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.ads.googleads.v21.common.UserListLogicalRuleInfo)) {
return super.equals(obj);
}
com.google.ads.googleads.v21.common.UserListLogicalRuleInfo other = (com.google.ads.googleads.v21.common.UserListLogicalRuleInfo) obj;
if (operator_ != other.operator_) return false;
if (!getRuleOperandsList()
.equals(other.getRuleOperandsList())) 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();
hash = (37 * hash) + OPERATOR_FIELD_NUMBER;
hash = (53 * hash) + operator_;
if (getRuleOperandsCount() > 0) {
hash = (37 * hash) + RULE_OPERANDS_FIELD_NUMBER;
hash = (53 * hash) + getRuleOperandsList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo 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.ads.googleads.v21.common.UserListLogicalRuleInfo parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo 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.ads.googleads.v21.common.UserListLogicalRuleInfo parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo 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.ads.googleads.v21.common.UserListLogicalRuleInfo parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo 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.ads.googleads.v21.common.UserListLogicalRuleInfo 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;
}
/**
* <pre>
* A user list logical rule. A rule has a logical operator (and/or/not) and a
* list of user lists as operands.
* </pre>
*
* Protobuf type {@code google.ads.googleads.v21.common.UserListLogicalRuleInfo}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:google.ads.googleads.v21.common.UserListLogicalRuleInfo)
com.google.ads.googleads.v21.common.UserListLogicalRuleInfoOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v21.common.UserListsProto.internal_static_google_ads_googleads_v21_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v21.common.UserListsProto.internal_static_google_ads_googleads_v21_common_UserListLogicalRuleInfo_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v21.common.UserListLogicalRuleInfo.class, com.google.ads.googleads.v21.common.UserListLogicalRuleInfo.Builder.class);
}
// Construct using com.google.ads.googleads.v21.common.UserListLogicalRuleInfo.newBuilder()
private Builder() {
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
operator_ = 0;
if (ruleOperandsBuilder_ == null) {
ruleOperands_ = java.util.Collections.emptyList();
} else {
ruleOperands_ = null;
ruleOperandsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000002);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return com.google.ads.googleads.v21.common.UserListsProto.internal_static_google_ads_googleads_v21_common_UserListLogicalRuleInfo_descriptor;
}
@java.lang.Override
public com.google.ads.googleads.v21.common.UserListLogicalRuleInfo getDefaultInstanceForType() {
return com.google.ads.googleads.v21.common.UserListLogicalRuleInfo.getDefaultInstance();
}
@java.lang.Override
public com.google.ads.googleads.v21.common.UserListLogicalRuleInfo build() {
com.google.ads.googleads.v21.common.UserListLogicalRuleInfo result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.ads.googleads.v21.common.UserListLogicalRuleInfo buildPartial() {
com.google.ads.googleads.v21.common.UserListLogicalRuleInfo result = new com.google.ads.googleads.v21.common.UserListLogicalRuleInfo(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartialRepeatedFields(com.google.ads.googleads.v21.common.UserListLogicalRuleInfo result) {
if (ruleOperandsBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)) {
ruleOperands_ = java.util.Collections.unmodifiableList(ruleOperands_);
bitField0_ = (bitField0_ & ~0x00000002);
}
result.ruleOperands_ = ruleOperands_;
} else {
result.ruleOperands_ = ruleOperandsBuilder_.build();
}
}
private void buildPartial0(com.google.ads.googleads.v21.common.UserListLogicalRuleInfo result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.operator_ = operator_;
}
}
@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.ads.googleads.v21.common.UserListLogicalRuleInfo) {
return mergeFrom((com.google.ads.googleads.v21.common.UserListLogicalRuleInfo)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.ads.googleads.v21.common.UserListLogicalRuleInfo other) {
if (other == com.google.ads.googleads.v21.common.UserListLogicalRuleInfo.getDefaultInstance()) return this;
if (other.operator_ != 0) {
setOperatorValue(other.getOperatorValue());
}
if (ruleOperandsBuilder_ == null) {
if (!other.ruleOperands_.isEmpty()) {
if (ruleOperands_.isEmpty()) {
ruleOperands_ = other.ruleOperands_;
bitField0_ = (bitField0_ & ~0x00000002);
} else {
ensureRuleOperandsIsMutable();
ruleOperands_.addAll(other.ruleOperands_);
}
onChanged();
}
} else {
if (!other.ruleOperands_.isEmpty()) {
if (ruleOperandsBuilder_.isEmpty()) {
ruleOperandsBuilder_.dispose();
ruleOperandsBuilder_ = null;
ruleOperands_ = other.ruleOperands_;
bitField0_ = (bitField0_ & ~0x00000002);
ruleOperandsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
getRuleOperandsFieldBuilder() : null;
} else {
ruleOperandsBuilder_.addAllMessages(other.ruleOperands_);
}
}
}
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 8: {
operator_ = input.readEnum();
bitField0_ |= 0x00000001;
break;
} // case 8
case 18: {
com.google.ads.googleads.v21.common.LogicalUserListOperandInfo m =
input.readMessage(
com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.parser(),
extensionRegistry);
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(m);
} else {
ruleOperandsBuilder_.addMessage(m);
}
break;
} // case 18
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 int operator_ = 0;
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The enum numeric value on the wire for operator.
*/
@java.lang.Override public int getOperatorValue() {
return operator_;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @param value The enum numeric value on the wire for operator to set.
* @return This builder for chaining.
*/
public Builder setOperatorValue(int value) {
operator_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return The operator.
*/
@java.lang.Override
public com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator getOperator() {
com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator result = com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.forNumber(operator_);
return result == null ? com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator.UNRECOGNIZED : result;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @param value The operator to set.
* @return This builder for chaining.
*/
public Builder setOperator(com.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000001;
operator_ = value.getNumber();
onChanged();
return this;
}
/**
* <pre>
* The logical operator of the rule.
* </pre>
*
* <code>.google.ads.googleads.v21.enums.UserListLogicalRuleOperatorEnum.UserListLogicalRuleOperator operator = 1;</code>
* @return This builder for chaining.
*/
public Builder clearOperator() {
bitField0_ = (bitField0_ & ~0x00000001);
operator_ = 0;
onChanged();
return this;
}
private java.util.List<com.google.ads.googleads.v21.common.LogicalUserListOperandInfo> ruleOperands_ =
java.util.Collections.emptyList();
private void ensureRuleOperandsIsMutable() {
if (!((bitField0_ & 0x00000002) != 0)) {
ruleOperands_ = new java.util.ArrayList<com.google.ads.googleads.v21.common.LogicalUserListOperandInfo>(ruleOperands_);
bitField0_ |= 0x00000002;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v21.common.LogicalUserListOperandInfo, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v21.common.LogicalUserListOperandInfoOrBuilder> ruleOperandsBuilder_;
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<com.google.ads.googleads.v21.common.LogicalUserListOperandInfo> getRuleOperandsList() {
if (ruleOperandsBuilder_ == null) {
return java.util.Collections.unmodifiableList(ruleOperands_);
} else {
return ruleOperandsBuilder_.getMessageList();
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public int getRuleOperandsCount() {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.size();
} else {
return ruleOperandsBuilder_.getCount();
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v21.common.LogicalUserListOperandInfo getRuleOperands(int index) {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.get(index);
} else {
return ruleOperandsBuilder_.getMessage(index);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder setRuleOperands(
int index, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.set(index, value);
onChanged();
} else {
ruleOperandsBuilder_.setMessage(index, value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder setRuleOperands(
int index, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.set(index, builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(com.google.ads.googleads.v21.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.add(value);
onChanged();
} else {
ruleOperandsBuilder_.addMessage(value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
int index, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo value) {
if (ruleOperandsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRuleOperandsIsMutable();
ruleOperands_.add(index, value);
onChanged();
} else {
ruleOperandsBuilder_.addMessage(index, value);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addRuleOperands(
int index, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder builderForValue) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.add(index, builderForValue.build());
onChanged();
} else {
ruleOperandsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder addAllRuleOperands(
java.lang.Iterable<? extends com.google.ads.googleads.v21.common.LogicalUserListOperandInfo> values) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
values, ruleOperands_);
onChanged();
} else {
ruleOperandsBuilder_.addAllMessages(values);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder clearRuleOperands() {
if (ruleOperandsBuilder_ == null) {
ruleOperands_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
} else {
ruleOperandsBuilder_.clear();
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public Builder removeRuleOperands(int index) {
if (ruleOperandsBuilder_ == null) {
ensureRuleOperandsIsMutable();
ruleOperands_.remove(index);
onChanged();
} else {
ruleOperandsBuilder_.remove(index);
}
return this;
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder getRuleOperandsBuilder(
int index) {
return getRuleOperandsFieldBuilder().getBuilder(index);
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v21.common.LogicalUserListOperandInfoOrBuilder getRuleOperandsOrBuilder(
int index) {
if (ruleOperandsBuilder_ == null) {
return ruleOperands_.get(index); } else {
return ruleOperandsBuilder_.getMessageOrBuilder(index);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<? extends com.google.ads.googleads.v21.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsOrBuilderList() {
if (ruleOperandsBuilder_ != null) {
return ruleOperandsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(ruleOperands_);
}
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder addRuleOperandsBuilder() {
return getRuleOperandsFieldBuilder().addBuilder(
com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.getDefaultInstance());
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder addRuleOperandsBuilder(
int index) {
return getRuleOperandsFieldBuilder().addBuilder(
index, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.getDefaultInstance());
}
/**
* <pre>
* The list of operands of the rule.
* </pre>
*
* <code>repeated .google.ads.googleads.v21.common.LogicalUserListOperandInfo rule_operands = 2;</code>
*/
public java.util.List<com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder>
getRuleOperandsBuilderList() {
return getRuleOperandsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v21.common.LogicalUserListOperandInfo, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v21.common.LogicalUserListOperandInfoOrBuilder>
getRuleOperandsFieldBuilder() {
if (ruleOperandsBuilder_ == null) {
ruleOperandsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.ads.googleads.v21.common.LogicalUserListOperandInfo, com.google.ads.googleads.v21.common.LogicalUserListOperandInfo.Builder, com.google.ads.googleads.v21.common.LogicalUserListOperandInfoOrBuilder>(
ruleOperands_,
((bitField0_ & 0x00000002) != 0),
getParentForChildren(),
isClean());
ruleOperands_ = null;
}
return ruleOperandsBuilder_;
}
@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.ads.googleads.v21.common.UserListLogicalRuleInfo)
}
// @@protoc_insertion_point(class_scope:google.ads.googleads.v21.common.UserListLogicalRuleInfo)
private static final com.google.ads.googleads.v21.common.UserListLogicalRuleInfo DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.ads.googleads.v21.common.UserListLogicalRuleInfo();
}
public static com.google.ads.googleads.v21.common.UserListLogicalRuleInfo getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UserListLogicalRuleInfo>
PARSER = new com.google.protobuf.AbstractParser<UserListLogicalRuleInfo>() {
@java.lang.Override
public UserListLogicalRuleInfo 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<UserListLogicalRuleInfo> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UserListLogicalRuleInfo> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.ads.googleads.v21.common.UserListLogicalRuleInfo getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,251 | java-analyticshub/proto-google-cloud-analyticshub-v1/src/main/java/com/google/cloud/bigquery/analyticshub/v1/ListListingsResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.bigquery.analyticshub.v1;
/**
*
*
* <pre>
* Message for response to the list of Listings.
* </pre>
*
* Protobuf type {@code google.cloud.bigquery.analyticshub.v1.ListListingsResponse}
*/
public final class ListListingsResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.bigquery.analyticshub.v1.ListListingsResponse)
ListListingsResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListListingsResponse.newBuilder() to construct.
private ListListingsResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListListingsResponse() {
listings_ = java.util.Collections.emptyList();
nextPageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListListingsResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.bigquery.analyticshub.v1.AnalyticsHubProto
.internal_static_google_cloud_bigquery_analyticshub_v1_ListListingsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.bigquery.analyticshub.v1.AnalyticsHubProto
.internal_static_google_cloud_bigquery_analyticshub_v1_ListListingsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse.class,
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse.Builder.class);
}
public static final int LISTINGS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.bigquery.analyticshub.v1.Listing> listings_;
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.bigquery.analyticshub.v1.Listing> getListingsList() {
return listings_;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.cloud.bigquery.analyticshub.v1.ListingOrBuilder>
getListingsOrBuilderList() {
return listings_;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
@java.lang.Override
public int getListingsCount() {
return listings_.size();
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
@java.lang.Override
public com.google.cloud.bigquery.analyticshub.v1.Listing getListings(int index) {
return listings_.get(index);
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
@java.lang.Override
public com.google.cloud.bigquery.analyticshub.v1.ListingOrBuilder getListingsOrBuilder(
int index) {
return listings_.get(index);
}
public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* A token to request the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
@java.lang.Override
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
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();
nextPageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* A token to request the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 {
for (int i = 0; i < listings_.size(); i++) {
output.writeMessage(1, listings_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < listings_.size(); i++) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, listings_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_);
}
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.bigquery.analyticshub.v1.ListListingsResponse)) {
return super.equals(obj);
}
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse other =
(com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse) obj;
if (!getListingsList().equals(other.getListingsList())) return false;
if (!getNextPageToken().equals(other.getNextPageToken())) 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 (getListingsCount() > 0) {
hash = (37 * hash) + LISTINGS_FIELD_NUMBER;
hash = (53 * hash) + getListingsList().hashCode();
}
hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getNextPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse 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.bigquery.analyticshub.v1.ListListingsResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse 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.bigquery.analyticshub.v1.ListListingsResponse parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse 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.bigquery.analyticshub.v1.ListListingsResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse 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.bigquery.analyticshub.v1.ListListingsResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse 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.bigquery.analyticshub.v1.ListListingsResponse 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;
}
/**
*
*
* <pre>
* Message for response to the list of Listings.
* </pre>
*
* Protobuf type {@code google.cloud.bigquery.analyticshub.v1.ListListingsResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.bigquery.analyticshub.v1.ListListingsResponse)
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.bigquery.analyticshub.v1.AnalyticsHubProto
.internal_static_google_cloud_bigquery_analyticshub_v1_ListListingsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.bigquery.analyticshub.v1.AnalyticsHubProto
.internal_static_google_cloud_bigquery_analyticshub_v1_ListListingsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse.class,
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse.Builder.class);
}
// Construct using com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (listingsBuilder_ == null) {
listings_ = java.util.Collections.emptyList();
} else {
listings_ = null;
listingsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
nextPageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.bigquery.analyticshub.v1.AnalyticsHubProto
.internal_static_google_cloud_bigquery_analyticshub_v1_ListListingsResponse_descriptor;
}
@java.lang.Override
public com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse
getDefaultInstanceForType() {
return com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse build() {
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse buildPartial() {
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse result =
new com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse result) {
if (listingsBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
listings_ = java.util.Collections.unmodifiableList(listings_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.listings_ = listings_;
} else {
result.listings_ = listingsBuilder_.build();
}
}
private void buildPartial0(
com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.nextPageToken_ = nextPageToken_;
}
}
@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.bigquery.analyticshub.v1.ListListingsResponse) {
return mergeFrom((com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse other) {
if (other
== com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse.getDefaultInstance())
return this;
if (listingsBuilder_ == null) {
if (!other.listings_.isEmpty()) {
if (listings_.isEmpty()) {
listings_ = other.listings_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureListingsIsMutable();
listings_.addAll(other.listings_);
}
onChanged();
}
} else {
if (!other.listings_.isEmpty()) {
if (listingsBuilder_.isEmpty()) {
listingsBuilder_.dispose();
listingsBuilder_ = null;
listings_ = other.listings_;
bitField0_ = (bitField0_ & ~0x00000001);
listingsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getListingsFieldBuilder()
: null;
} else {
listingsBuilder_.addAllMessages(other.listings_);
}
}
}
if (!other.getNextPageToken().isEmpty()) {
nextPageToken_ = other.nextPageToken_;
bitField0_ |= 0x00000002;
onChanged();
}
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 10:
{
com.google.cloud.bigquery.analyticshub.v1.Listing m =
input.readMessage(
com.google.cloud.bigquery.analyticshub.v1.Listing.parser(),
extensionRegistry);
if (listingsBuilder_ == null) {
ensureListingsIsMutable();
listings_.add(m);
} else {
listingsBuilder_.addMessage(m);
}
break;
} // case 10
case 18:
{
nextPageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
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.bigquery.analyticshub.v1.Listing> listings_ =
java.util.Collections.emptyList();
private void ensureListingsIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
listings_ =
new java.util.ArrayList<com.google.cloud.bigquery.analyticshub.v1.Listing>(listings_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.bigquery.analyticshub.v1.Listing,
com.google.cloud.bigquery.analyticshub.v1.Listing.Builder,
com.google.cloud.bigquery.analyticshub.v1.ListingOrBuilder>
listingsBuilder_;
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public java.util.List<com.google.cloud.bigquery.analyticshub.v1.Listing> getListingsList() {
if (listingsBuilder_ == null) {
return java.util.Collections.unmodifiableList(listings_);
} else {
return listingsBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public int getListingsCount() {
if (listingsBuilder_ == null) {
return listings_.size();
} else {
return listingsBuilder_.getCount();
}
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public com.google.cloud.bigquery.analyticshub.v1.Listing getListings(int index) {
if (listingsBuilder_ == null) {
return listings_.get(index);
} else {
return listingsBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder setListings(int index, com.google.cloud.bigquery.analyticshub.v1.Listing value) {
if (listingsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureListingsIsMutable();
listings_.set(index, value);
onChanged();
} else {
listingsBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder setListings(
int index, com.google.cloud.bigquery.analyticshub.v1.Listing.Builder builderForValue) {
if (listingsBuilder_ == null) {
ensureListingsIsMutable();
listings_.set(index, builderForValue.build());
onChanged();
} else {
listingsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder addListings(com.google.cloud.bigquery.analyticshub.v1.Listing value) {
if (listingsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureListingsIsMutable();
listings_.add(value);
onChanged();
} else {
listingsBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder addListings(int index, com.google.cloud.bigquery.analyticshub.v1.Listing value) {
if (listingsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureListingsIsMutable();
listings_.add(index, value);
onChanged();
} else {
listingsBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder addListings(
com.google.cloud.bigquery.analyticshub.v1.Listing.Builder builderForValue) {
if (listingsBuilder_ == null) {
ensureListingsIsMutable();
listings_.add(builderForValue.build());
onChanged();
} else {
listingsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder addListings(
int index, com.google.cloud.bigquery.analyticshub.v1.Listing.Builder builderForValue) {
if (listingsBuilder_ == null) {
ensureListingsIsMutable();
listings_.add(index, builderForValue.build());
onChanged();
} else {
listingsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder addAllListings(
java.lang.Iterable<? extends com.google.cloud.bigquery.analyticshub.v1.Listing> values) {
if (listingsBuilder_ == null) {
ensureListingsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, listings_);
onChanged();
} else {
listingsBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder clearListings() {
if (listingsBuilder_ == null) {
listings_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
listingsBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public Builder removeListings(int index) {
if (listingsBuilder_ == null) {
ensureListingsIsMutable();
listings_.remove(index);
onChanged();
} else {
listingsBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public com.google.cloud.bigquery.analyticshub.v1.Listing.Builder getListingsBuilder(int index) {
return getListingsFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public com.google.cloud.bigquery.analyticshub.v1.ListingOrBuilder getListingsOrBuilder(
int index) {
if (listingsBuilder_ == null) {
return listings_.get(index);
} else {
return listingsBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public java.util.List<? extends com.google.cloud.bigquery.analyticshub.v1.ListingOrBuilder>
getListingsOrBuilderList() {
if (listingsBuilder_ != null) {
return listingsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(listings_);
}
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public com.google.cloud.bigquery.analyticshub.v1.Listing.Builder addListingsBuilder() {
return getListingsFieldBuilder()
.addBuilder(com.google.cloud.bigquery.analyticshub.v1.Listing.getDefaultInstance());
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public com.google.cloud.bigquery.analyticshub.v1.Listing.Builder addListingsBuilder(int index) {
return getListingsFieldBuilder()
.addBuilder(
index, com.google.cloud.bigquery.analyticshub.v1.Listing.getDefaultInstance());
}
/**
*
*
* <pre>
* The list of Listing.
* </pre>
*
* <code>repeated .google.cloud.bigquery.analyticshub.v1.Listing listings = 1;</code>
*/
public java.util.List<com.google.cloud.bigquery.analyticshub.v1.Listing.Builder>
getListingsBuilderList() {
return getListingsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.bigquery.analyticshub.v1.Listing,
com.google.cloud.bigquery.analyticshub.v1.Listing.Builder,
com.google.cloud.bigquery.analyticshub.v1.ListingOrBuilder>
getListingsFieldBuilder() {
if (listingsBuilder_ == null) {
listingsBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.bigquery.analyticshub.v1.Listing,
com.google.cloud.bigquery.analyticshub.v1.Listing.Builder,
com.google.cloud.bigquery.analyticshub.v1.ListingOrBuilder>(
listings_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
listings_ = null;
}
return listingsBuilder_;
}
private java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* A token to request the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
nextPageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* A token to request the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* A token to request the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* A token to request the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearNextPageToken() {
nextPageToken_ = getDefaultInstance().getNextPageToken();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* A token to request the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The bytes for nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.bigquery.analyticshub.v1.ListListingsResponse)
}
// @@protoc_insertion_point(class_scope:google.cloud.bigquery.analyticshub.v1.ListListingsResponse)
private static final com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse();
}
public static com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListListingsResponse> PARSER =
new com.google.protobuf.AbstractParser<ListListingsResponse>() {
@java.lang.Override
public ListListingsResponse 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<ListListingsResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListListingsResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.bigquery.analyticshub.v1.ListListingsResponse
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
google/filament | 36,289 | third_party/dawn/third_party/protobuf/java/core/src/test/java/com/google/protobuf/ByteStringTest.java | // Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.protobuf.ByteString.Output;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Test methods with implementations in {@link ByteString}, plus do some top-level "integration"
* tests.
*/
@RunWith(JUnit4.class)
public class ByteStringTest {
private static final Charset UTF_16 = Charset.forName("UTF-16");
static byte[] getTestBytes(int size, long seed) {
Random random = new Random(seed);
byte[] result = new byte[size];
random.nextBytes(result);
return result;
}
private static byte[] getTestBytes(int size) {
return getTestBytes(size, 445566L);
}
private static byte[] getTestBytes() {
return getTestBytes(1000);
}
// Compare the entire left array with a subset of the right array.
private static boolean isArrayRange(byte[] left, byte[] right, int rightOffset, int length) {
boolean stillEqual = (left.length == length);
for (int i = 0; (stillEqual && i < length); ++i) {
stillEqual = (left[i] == right[rightOffset + i]);
}
return stillEqual;
}
// Returns true only if the given two arrays have identical contents.
private static boolean isArray(byte[] left, byte[] right) {
return left.length == right.length && isArrayRange(left, right, 0, left.length);
}
@Test
public void testCompare_equalByteStrings_compareEqual() throws Exception {
byte[] referenceBytes = getTestBytes();
ByteString string1 = ByteString.copyFrom(referenceBytes);
ByteString string2 = ByteString.copyFrom(referenceBytes);
assertWithMessage("ByteString instances containing the same data must compare equal.")
.that(ByteString.unsignedLexicographicalComparator().compare(string1, string2))
.isEqualTo(0);
}
@Test
public void testCompare_byteStringsSortLexicographically() throws Exception {
ByteString app = ByteString.copyFromUtf8("app");
ByteString apple = ByteString.copyFromUtf8("apple");
ByteString banana = ByteString.copyFromUtf8("banana");
Comparator<ByteString> comparator = ByteString.unsignedLexicographicalComparator();
assertWithMessage("ByteString(app) < ByteString(apple)")
.that(comparator.compare(app, apple) < 0)
.isTrue();
assertWithMessage("ByteString(app) < ByteString(banana)")
.that(comparator.compare(app, banana) < 0)
.isTrue();
assertWithMessage("ByteString(apple) < ByteString(banana)")
.that(comparator.compare(apple, banana) < 0)
.isTrue();
}
@Test
public void testCompare_interpretsByteValuesAsUnsigned() throws Exception {
// Two's compliment of `-1` == 0b11111111 == 255
ByteString twoHundredFiftyFive = ByteString.copyFrom(new byte[] {-1});
// 0b00000001 == 1
ByteString one = ByteString.copyFrom(new byte[] {1});
assertWithMessage("ByteString comparison treats bytes as unsigned values")
.that(ByteString.unsignedLexicographicalComparator().compare(one, twoHundredFiftyFive) < 0)
.isTrue();
}
@Test
public void testSubstring_beginIndex() {
byte[] bytes = getTestBytes();
ByteString substring = ByteString.copyFrom(bytes).substring(500);
assertWithMessage("substring must contain the tail of the string")
.that(isArrayRange(substring.toByteArray(), bytes, 500, bytes.length - 500))
.isTrue();
}
@Test
public void testEmpty_isEmpty() {
ByteString byteString = ByteString.empty();
assertThat(byteString.isEmpty()).isTrue();
assertWithMessage("ByteString.empty() must return empty byte array")
.that(isArray(byteString.toByteArray(), new byte[] {}))
.isTrue();
}
@Test
public void testEmpty_referenceEquality() {
assertThat(ByteString.empty()).isSameInstanceAs(ByteString.EMPTY);
assertThat(ByteString.empty()).isSameInstanceAs(ByteString.empty());
}
@Test
public void testFromHex_hexString() {
ByteString byteString;
byteString = ByteString.fromHex("0a0b0c");
assertWithMessage("fromHex must contain the expected bytes")
.that(isArray(byteString.toByteArray(), new byte[] {0x0a, 0x0b, 0x0c}))
.isTrue();
byteString = ByteString.fromHex("0A0B0C");
assertWithMessage("fromHex must contain the expected bytes")
.that(isArray(byteString.toByteArray(), new byte[] {0x0a, 0x0b, 0x0c}))
.isTrue();
byteString = ByteString.fromHex("0a0b0c0d0e0f");
assertWithMessage("fromHex must contain the expected bytes")
.that(isArray(byteString.toByteArray(), new byte[] {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}))
.isTrue();
}
@Test
@SuppressWarnings("AlwaysThrows") // Verifying that indeed these calls do throw.
public void testFromHex_invalidHexString() {
try {
ByteString.fromHex("a0b0c");
assertWithMessage("Should throw").fail();
} catch (NumberFormatException expected) {
assertThat(expected).hasMessageThat().contains("even");
}
try {
ByteString.fromHex("0x0y0z");
assertWithMessage("Should throw").fail();
} catch (NumberFormatException expected) {
assertThat(expected).hasMessageThat().contains("[0-9a-fA-F]");
}
try {
ByteString.fromHex("0૫");
assertWithMessage("Should throw").fail();
} catch (NumberFormatException expected) {
assertThat(expected).hasMessageThat().contains("[0-9a-fA-F]");
}
}
@Test
public void testCopyFrom_bytesOffsetSize() {
byte[] bytes = getTestBytes();
ByteString byteString = ByteString.copyFrom(bytes, 500, 200);
assertWithMessage("copyFrom sub-range must contain the expected bytes")
.that(isArrayRange(byteString.toByteArray(), bytes, 500, 200))
.isTrue();
}
@Test
public void testCopyFrom_bytes() {
byte[] bytes = getTestBytes();
ByteString byteString = ByteString.copyFrom(bytes);
assertWithMessage("copyFrom must contain the expected bytes")
.that(isArray(byteString.toByteArray(), bytes))
.isTrue();
}
@Test
public void testCopyFrom_byteBufferSize() {
byte[] bytes = getTestBytes();
ByteBuffer byteBuffer = ByteBuffer.allocate(bytes.length);
byteBuffer.put(bytes);
byteBuffer.position(500);
ByteString byteString = ByteString.copyFrom(byteBuffer, 200);
assertWithMessage("copyFrom byteBuffer sub-range must contain the expected bytes")
.that(isArrayRange(byteString.toByteArray(), bytes, 500, 200))
.isTrue();
}
@Test
public void testCopyFrom_byteBuffer() {
byte[] bytes = getTestBytes();
ByteBuffer byteBuffer = ByteBuffer.allocate(bytes.length);
byteBuffer.put(bytes);
byteBuffer.position(500);
ByteString byteString = ByteString.copyFrom(byteBuffer);
assertWithMessage("copyFrom byteBuffer sub-range must contain the expected bytes")
.that(isArrayRange(byteString.toByteArray(), bytes, 500, bytes.length - 500))
.isTrue();
}
@Test
public void testCopyFrom_stringEncoding() {
String testString = "I love unicode \u1234\u5678 characters";
ByteString byteString = ByteString.copyFrom(testString, UTF_16);
byte[] testBytes = testString.getBytes(UTF_16);
assertWithMessage("copyFrom string must respect the charset")
.that(isArrayRange(byteString.toByteArray(), testBytes, 0, testBytes.length))
.isTrue();
}
@Test
public void testCopyFrom_utf8() {
String testString = "I love unicode \u1234\u5678 characters";
ByteString byteString = ByteString.copyFromUtf8(testString);
byte[] testBytes = testString.getBytes(Internal.UTF_8);
assertWithMessage("copyFromUtf8 string must respect the charset")
.that(isArrayRange(byteString.toByteArray(), testBytes, 0, testBytes.length))
.isTrue();
}
@Test
public void testCopyFrom_iterable() {
byte[] testBytes = getTestBytes(77777, 113344L);
final List<ByteString> pieces = makeConcretePieces(testBytes);
// Call copyFrom() on a Collection
ByteString byteString = ByteString.copyFrom(pieces);
assertWithMessage("copyFrom a List must contain the expected bytes")
.that(isArrayRange(byteString.toByteArray(), testBytes, 0, testBytes.length))
.isTrue();
// Call copyFrom on an iteration that's not a collection
ByteString byteStringAlt =
ByteString.copyFrom(
new Iterable<ByteString>() {
@Override
public Iterator<ByteString> iterator() {
return pieces.iterator();
}
});
assertWithMessage("copyFrom from an Iteration must contain the expected bytes")
.that(byteString)
.isEqualTo(byteStringAlt);
}
@Test
public void testCopyFrom_lengthTooBig() {
byte[] testBytes = getTestBytes(100);
try {
ByteString.copyFrom(testBytes, 0, 200);
assertWithMessage("Should throw").fail();
} catch (IndexOutOfBoundsException expected) {
}
try {
ByteString.copyFrom(testBytes, 99, 2);
assertWithMessage("Should throw").fail();
} catch (IndexOutOfBoundsException expected) {
}
ByteBuffer buf = ByteBuffer.wrap(testBytes);
try {
ByteString.copyFrom(buf, 101);
assertWithMessage("Should throw").fail();
} catch (IndexOutOfBoundsException expected) {
}
try {
ByteString.copyFrom(testBytes, -1, 10);
assertWithMessage("Should throw").fail();
} catch (IndexOutOfBoundsException expected) {
}
}
@Test
public void testCopyTo_targetOffset() {
byte[] bytes = getTestBytes();
ByteString byteString = ByteString.copyFrom(bytes);
byte[] target = new byte[bytes.length + 1000];
byteString.copyTo(target, 400);
assertWithMessage("copyFrom byteBuffer sub-range must contain the expected bytes")
.that(isArrayRange(bytes, target, 400, bytes.length))
.isTrue();
}
@Test
public void testReadFrom_emptyStream() throws IOException {
ByteString byteString = ByteString.readFrom(new ByteArrayInputStream(new byte[0]));
assertWithMessage("reading an empty stream must result in the EMPTY constant byte string")
.that(ByteString.EMPTY)
.isSameInstanceAs(byteString);
}
@Test
public void testReadFrom_smallStream() throws IOException {
assertReadFrom(getTestBytes(10));
}
@Test
public void testReadFrom_mutating() throws IOException {
EvilInputStream eis = new EvilInputStream();
ByteString byteString = ByteString.readFrom(eis);
byte[] capturedArray = eis.capturedArray;
byte[] originalValue = byteString.toByteArray();
for (int x = 0; x < capturedArray.length; ++x) {
capturedArray[x] = (byte) 0;
}
byte[] newValue = byteString.toByteArray();
assertWithMessage("copyFrom byteBuffer must not grant access to underlying array")
.that(Arrays.equals(originalValue, newValue))
.isTrue();
}
// Tests sizes that are near the rope copy-out threshold.
@Test
public void testReadFrom_mediumStream() throws IOException {
assertReadFrom(getTestBytes(ByteString.CONCATENATE_BY_COPY_SIZE - 1));
assertReadFrom(getTestBytes(ByteString.CONCATENATE_BY_COPY_SIZE));
assertReadFrom(getTestBytes(ByteString.CONCATENATE_BY_COPY_SIZE + 1));
assertReadFrom(getTestBytes(200));
}
// Tests sizes that are over multi-segment rope threshold.
@Test
public void testReadFrom_largeStream() throws IOException {
assertReadFrom(getTestBytes(0x100));
assertReadFrom(getTestBytes(0x101));
assertReadFrom(getTestBytes(0x110));
assertReadFrom(getTestBytes(0x1000));
assertReadFrom(getTestBytes(0x1001));
assertReadFrom(getTestBytes(0x1010));
assertReadFrom(getTestBytes(0x10000));
assertReadFrom(getTestBytes(0x10001));
assertReadFrom(getTestBytes(0x10010));
}
// Tests sizes that are near the read buffer size.
@Test
public void testReadFrom_byteBoundaries() throws IOException {
final int min = ByteString.MIN_READ_FROM_CHUNK_SIZE;
final int max = ByteString.MAX_READ_FROM_CHUNK_SIZE;
assertReadFrom(getTestBytes(min - 1));
assertReadFrom(getTestBytes(min));
assertReadFrom(getTestBytes(min + 1));
assertReadFrom(getTestBytes(min * 2 - 1));
assertReadFrom(getTestBytes(min * 2));
assertReadFrom(getTestBytes(min * 2 + 1));
assertReadFrom(getTestBytes(min * 4 - 1));
assertReadFrom(getTestBytes(min * 4));
assertReadFrom(getTestBytes(min * 4 + 1));
assertReadFrom(getTestBytes(min * 8 - 1));
assertReadFrom(getTestBytes(min * 8));
assertReadFrom(getTestBytes(min * 8 + 1));
assertReadFrom(getTestBytes(max - 1));
assertReadFrom(getTestBytes(max));
assertReadFrom(getTestBytes(max + 1));
assertReadFrom(getTestBytes(max * 2 - 1));
assertReadFrom(getTestBytes(max * 2));
assertReadFrom(getTestBytes(max * 2 + 1));
}
// Tests that IOExceptions propagate through ByteString.readFrom().
@Test
public void testReadFrom_iOExceptions() {
try {
ByteString.readFrom(new FailStream());
assertWithMessage("readFrom must throw the underlying IOException").fail();
} catch (IOException e) {
assertWithMessage("readFrom must throw the expected exception")
.that(e)
.hasMessageThat()
.isEqualTo("synthetic failure");
}
}
// Tests that ByteString.readFrom works with streams that don't
// always fill their buffers.
@Test
public void testReadFrom_reluctantStream() throws IOException {
final byte[] data = getTestBytes(0x1000);
ByteString byteString = ByteString.readFrom(new ReluctantStream(data));
assertWithMessage("readFrom byte stream must contain the expected bytes")
.that(isArray(byteString.toByteArray(), data))
.isTrue();
// Same test as above, but with some specific chunk sizes.
assertReadFromReluctantStream(data, 100);
assertReadFromReluctantStream(data, 248);
assertReadFromReluctantStream(data, 249);
assertReadFromReluctantStream(data, 250);
assertReadFromReluctantStream(data, 251);
assertReadFromReluctantStream(data, 0x1000);
assertReadFromReluctantStream(data, 0x1001);
}
// Fails unless ByteString.readFrom reads the bytes correctly from a
// reluctant stream with the given chunkSize parameter.
private void assertReadFromReluctantStream(byte[] bytes, int chunkSize) throws IOException {
ByteString b = ByteString.readFrom(new ReluctantStream(bytes), chunkSize);
assertWithMessage("readFrom byte stream must contain the expected bytes")
.that(isArray(b.toByteArray(), bytes))
.isTrue();
}
// Tests that ByteString.readFrom works with streams that implement
// available().
@Test
public void testReadFrom_available() throws IOException {
final byte[] data = getTestBytes(0x1001);
ByteString byteString = ByteString.readFrom(new AvailableStream(data));
assertWithMessage("readFrom byte stream must contain the expected bytes")
.that(isArray(byteString.toByteArray(), data))
.isTrue();
}
// Fails unless ByteString.readFrom reads the bytes correctly.
private void assertReadFrom(byte[] bytes) throws IOException {
ByteString byteString = ByteString.readFrom(new ByteArrayInputStream(bytes));
assertWithMessage("readFrom byte stream must contain the expected bytes")
.that(isArray(byteString.toByteArray(), bytes))
.isTrue();
}
// A stream that fails when read.
private static final class FailStream extends InputStream {
@Override
public int read() throws IOException {
throw new IOException("synthetic failure");
}
}
// A stream that simulates blocking by only producing 250 characters
// per call to read(byte[]).
private static class ReluctantStream extends InputStream {
protected final byte[] data;
protected int pos = 0;
public ReluctantStream(byte[] data) {
this.data = data;
}
@Override
public int read() {
if (pos == data.length) {
return -1;
} else {
return data[pos++];
}
}
@Override
public int read(byte[] buf) {
return read(buf, 0, buf.length);
}
@Override
public int read(byte[] buf, int offset, int size) {
if (pos == data.length) {
return -1;
}
int count = Math.min(Math.min(size, data.length - pos), 250);
System.arraycopy(data, pos, buf, offset, count);
pos += count;
return count;
}
}
// Same as above, but also implements available().
private static final class AvailableStream extends ReluctantStream {
public AvailableStream(byte[] data) {
super(data);
}
@Override
public int available() {
return Math.min(250, data.length - pos);
}
}
// A stream which exposes the byte array passed into read(byte[], int, int).
private static class EvilInputStream extends InputStream {
public byte[] capturedArray = null;
@Override
public int read(byte[] buf, int off, int len) {
if (capturedArray != null) {
return -1;
} else {
capturedArray = buf;
for (int x = 0; x < len; ++x) {
buf[x] = (byte) x;
}
return len;
}
}
@Override
public int read() {
// Purposefully do nothing.
return -1;
}
}
// A stream which exposes the byte array passed into write(byte[], int, int).
private static class EvilOutputStream extends OutputStream {
public byte[] capturedArray = null;
@Override
public void write(byte[] buf, int off, int len) {
if (capturedArray == null) {
capturedArray = buf;
}
}
@Override
public void write(int ignored) {
// Purposefully do nothing.
}
}
@Test
public void testToStringUtf8() {
String testString = "I love unicode \u1234\u5678 characters";
byte[] testBytes = testString.getBytes(Internal.UTF_8);
ByteString byteString = ByteString.copyFrom(testBytes);
assertWithMessage("copyToStringUtf8 must respect the charset")
.that(testString)
.isEqualTo(byteString.toStringUtf8());
}
@Test
public void testToString() {
String toString =
ByteString.copyFrom("Here are some bytes: \t\u00a1".getBytes(Internal.UTF_8)).toString();
assertWithMessage(toString).that(toString.contains("size=24")).isTrue();
assertWithMessage(toString)
.that(toString.contains("contents=\"Here are some bytes: \\t\\302\\241\""))
.isTrue();
}
@Test
public void testToString_long() {
String toString =
ByteString.copyFrom(
"123456789012345678901234567890123456789012345678901234567890"
.getBytes(Internal.UTF_8))
.toString();
assertWithMessage(toString).that(toString.contains("size=60")).isTrue();
assertWithMessage(toString)
.that(toString.contains("contents=\"12345678901234567890123456789012345678901234567...\""))
.isTrue();
}
@Test
public void testNewOutput_initialCapacity() throws IOException {
byte[] bytes = getTestBytes();
ByteString.Output output = ByteString.newOutput(bytes.length + 100);
output.write(bytes);
ByteString byteString = output.toByteString();
assertWithMessage("String built from newOutput(int) must contain the expected bytes")
.that(isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length))
.isTrue();
}
// Test newOutput() using a variety of buffer sizes and a variety of (fixed)
// write sizes
@Test
public void testNewOutput_arrayWrite() {
byte[] bytes = getTestBytes();
int length = bytes.length;
int[] bufferSizes = {
128, 256, length / 2, length - 1, length, length + 1, 2 * length, 3 * length
};
int[] writeSizes = {1, 4, 5, 7, 23, bytes.length};
for (int bufferSize : bufferSizes) {
for (int writeSize : writeSizes) {
// Test writing the entire output writeSize bytes at a time.
ByteString.Output output = ByteString.newOutput(bufferSize);
for (int i = 0; i < length; i += writeSize) {
output.write(bytes, i, Math.min(writeSize, length - i));
}
ByteString byteString = output.toByteString();
assertWithMessage("String built from newOutput() must contain the expected bytes")
.that(isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length))
.isTrue();
}
}
}
// Test newOutput() using a variety of buffer sizes, but writing all the
// characters using write(byte);
@Test
public void testNewOutput_writeChar() {
byte[] bytes = getTestBytes();
int length = bytes.length;
int[] bufferSizes = {
0, 1, 128, 256, length / 2, length - 1, length, length + 1, 2 * length, 3 * length
};
for (int bufferSize : bufferSizes) {
ByteString.Output output = ByteString.newOutput(bufferSize);
for (byte byteValue : bytes) {
output.write(byteValue);
}
ByteString byteString = output.toByteString();
assertWithMessage("String built from newOutput() must contain the expected bytes")
.that(isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length))
.isTrue();
}
}
// Test newOutput() in which we write the bytes using a variety of methods
// and sizes, and in which we repeatedly call toByteString() in the middle.
@Test
public void testNewOutput_mixed() {
Random rng = new Random(1);
byte[] bytes = getTestBytes();
int length = bytes.length;
int[] bufferSizes = {
0, 1, 128, 256, length / 2, length - 1, length, length + 1, 2 * length, 3 * length
};
for (int bufferSize : bufferSizes) {
// Test writing the entire output using a mixture of write sizes and
// methods;
ByteString.Output output = ByteString.newOutput(bufferSize);
int position = 0;
while (position < bytes.length) {
if (rng.nextBoolean()) {
int count = 1 + rng.nextInt(bytes.length - position);
output.write(bytes, position, count);
position += count;
} else {
output.write(bytes[position]);
position++;
}
assertWithMessage("size() returns the right value").that(position).isEqualTo(output.size());
assertWithMessage("newOutput() substring must have correct bytes")
.that(isArrayRange(output.toByteString().toByteArray(), bytes, 0, position))
.isTrue();
}
ByteString byteString = output.toByteString();
assertWithMessage("String built from newOutput() must contain the expected bytes")
.that(isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length))
.isTrue();
}
}
@Test
public void testNewOutputEmpty() {
// Make sure newOutput() correctly builds empty byte strings
ByteString byteString = ByteString.newOutput().toByteString();
assertThat(ByteString.EMPTY).isEqualTo(byteString);
}
@Test
public void testNewOutput_mutating() throws IOException {
Output os = ByteString.newOutput(5);
os.write(new byte[] {1, 2, 3, 4, 5});
EvilOutputStream eos = new EvilOutputStream();
os.writeTo(eos);
byte[] capturedArray = eos.capturedArray;
ByteString byteString = os.toByteString();
byte[] oldValue = byteString.toByteArray();
Arrays.fill(capturedArray, (byte) 0);
byte[] newValue = byteString.toByteArray();
assertWithMessage("Output must not provide access to the underlying byte array")
.that(Arrays.equals(oldValue, newValue))
.isTrue();
}
@Test
public void testNewCodedBuilder() throws IOException {
byte[] bytes = getTestBytes();
ByteString.CodedBuilder builder = ByteString.newCodedBuilder(bytes.length);
builder.getCodedOutput().writeRawBytes(bytes);
ByteString byteString = builder.build();
assertWithMessage("String built from newCodedBuilder() must contain the expected bytes")
.that(isArrayRange(bytes, byteString.toByteArray(), 0, bytes.length))
.isTrue();
}
@Test
public void testSubstringParity() {
byte[] bigBytes = getTestBytes(2048 * 1024, 113344L);
int start = 512 * 1024 - 3333;
int end = 512 * 1024 + 7777;
ByteString concreteSubstring = ByteString.copyFrom(bigBytes).substring(start, end);
boolean ok = true;
for (int i = start; ok && i < end; ++i) {
ok = (bigBytes[i] == concreteSubstring.byteAt(i - start));
}
assertWithMessage("Concrete substring didn't capture the right bytes").that(ok).isTrue();
ByteString literalString = ByteString.copyFrom(bigBytes, start, end - start);
assertWithMessage("Substring must be equal to literal string")
.that(literalString)
.isEqualTo(concreteSubstring);
assertWithMessage("Substring must have same hashcode as literal string")
.that(literalString.hashCode())
.isEqualTo(concreteSubstring.hashCode());
}
@Test
public void testCompositeSubstring() {
byte[] referenceBytes = getTestBytes(77748, 113344L);
List<ByteString> pieces = makeConcretePieces(referenceBytes);
ByteString listString = ByteString.copyFrom(pieces);
int from = 1000;
int to = 40000;
ByteString compositeSubstring = listString.substring(from, to);
byte[] substringBytes = compositeSubstring.toByteArray();
boolean stillEqual = true;
for (int i = 0; stillEqual && i < to - from; ++i) {
stillEqual = referenceBytes[from + i] == substringBytes[i];
}
assertWithMessage("Substring must return correct bytes").that(stillEqual).isTrue();
stillEqual = true;
for (int i = 0; stillEqual && i < to - from; ++i) {
stillEqual = referenceBytes[from + i] == compositeSubstring.byteAt(i);
}
assertWithMessage("Substring must support byteAt() correctly").that(stillEqual).isTrue();
ByteString literalSubstring = ByteString.copyFrom(referenceBytes, from, to - from);
assertWithMessage("Composite substring must equal a literal substring over the same bytes")
.that(literalSubstring)
.isEqualTo(compositeSubstring);
assertWithMessage("Literal substring must equal a composite substring over the same bytes")
.that(compositeSubstring)
.isEqualTo(literalSubstring);
assertWithMessage("We must get the same hashcodes for composite and literal substrings")
.that(literalSubstring.hashCode())
.isEqualTo(compositeSubstring.hashCode());
assertWithMessage("We can't be equal to a proper substring")
.that(compositeSubstring.equals(literalSubstring.substring(0, literalSubstring.size() - 1)))
.isFalse();
}
@Test
public void testCopyFromList() {
byte[] referenceBytes = getTestBytes(77748, 113344L);
ByteString literalString = ByteString.copyFrom(referenceBytes);
List<ByteString> pieces = makeConcretePieces(referenceBytes);
ByteString listString = ByteString.copyFrom(pieces);
assertWithMessage("Composite string must be equal to literal string")
.that(literalString)
.isEqualTo(listString);
assertWithMessage("Composite string must have same hashcode as literal string")
.that(literalString.hashCode())
.isEqualTo(listString.hashCode());
}
@Test
public void testConcat() {
byte[] referenceBytes = getTestBytes(77748, 113344L);
ByteString literalString = ByteString.copyFrom(referenceBytes);
List<ByteString> pieces = makeConcretePieces(referenceBytes);
Iterator<ByteString> iter = pieces.iterator();
ByteString concatenatedString = iter.next();
while (iter.hasNext()) {
concatenatedString = concatenatedString.concat(iter.next());
}
assertWithMessage("Concatenated string must be equal to literal string")
.that(literalString)
.isEqualTo(concatenatedString);
assertWithMessage("Concatenated string must have same hashcode as literal string")
.that(literalString.hashCode())
.isEqualTo(concatenatedString.hashCode());
}
/**
* Test the Rope implementation can deal with Empty nodes, even though we guard against them. See
* also {@link LiteralByteStringTest#testConcat_empty()}.
*/
@Test
public void testConcat_empty() {
byte[] referenceBytes = getTestBytes(7748, 113344L);
ByteString literalString = ByteString.copyFrom(referenceBytes);
ByteString duo = RopeByteString.newInstanceForTest(literalString, literalString);
ByteString temp =
RopeByteString.newInstanceForTest(
RopeByteString.newInstanceForTest(literalString, ByteString.EMPTY),
RopeByteString.newInstanceForTest(ByteString.EMPTY, literalString));
ByteString quintet = RopeByteString.newInstanceForTest(temp, ByteString.EMPTY);
assertWithMessage("String with concatenated nulls must equal simple concatenate")
.that(quintet)
.isEqualTo(duo);
assertWithMessage("String with concatenated nulls have same hashcode as simple concatenate")
.that(duo.hashCode())
.isEqualTo(quintet.hashCode());
ByteString.ByteIterator duoIter = duo.iterator();
ByteString.ByteIterator quintetIter = quintet.iterator();
boolean stillEqual = true;
while (stillEqual && quintetIter.hasNext()) {
stillEqual = (duoIter.nextByte() == quintetIter.nextByte());
}
assertWithMessage("We must get the same characters by iterating").that(stillEqual).isTrue();
assertWithMessage("Iterator must be exhausted").that(duoIter.hasNext()).isFalse();
try {
duoIter.nextByte();
assertWithMessage("Should have thrown an exception.").fail();
} catch (NoSuchElementException e) {
// This is success
}
try {
quintetIter.nextByte();
assertWithMessage("Should have thrown an exception.").fail();
} catch (NoSuchElementException e) {
// This is success
}
// Test that even if we force empty strings in as rope leaves in this
// configuration, we always get a (possibly Bounded) LiteralByteString
// for a length 1 substring.
//
// It is possible, using the testing factory method to create deeply nested
// trees of empty leaves, to make a string that will fail this test.
for (int i = 1; i < duo.size(); ++i) {
assertWithMessage("Substrings of size() < 2 must not be RopeByteStrings")
.that(duo.substring(i - 1, i) instanceof ByteString.LeafByteString)
.isTrue();
}
for (int i = 1; i < quintet.size(); ++i) {
assertWithMessage("Substrings of size() < 2 must not be RopeByteStrings")
.that(quintet.substring(i - 1, i) instanceof ByteString.LeafByteString)
.isTrue();
}
}
@Test
public void testStartsWith() {
byte[] bytes = getTestBytes(1000, 1234L);
ByteString string = ByteString.copyFrom(bytes);
ByteString prefix = ByteString.copyFrom(bytes, 0, 500);
ByteString suffix = ByteString.copyFrom(bytes, 400, 600);
assertThat(string.startsWith(ByteString.EMPTY)).isTrue();
assertThat(string.startsWith(string)).isTrue();
assertThat(string.startsWith(prefix)).isTrue();
assertThat(string.startsWith(suffix)).isFalse();
assertThat(prefix.startsWith(suffix)).isFalse();
assertThat(suffix.startsWith(prefix)).isFalse();
assertThat(ByteString.EMPTY.startsWith(prefix)).isFalse();
assertThat(ByteString.EMPTY.startsWith(ByteString.EMPTY)).isTrue();
}
@Test
public void testEndsWith() {
byte[] bytes = getTestBytes(1000, 1234L);
ByteString string = ByteString.copyFrom(bytes);
ByteString prefix = ByteString.copyFrom(bytes, 0, 500);
ByteString suffix = ByteString.copyFrom(bytes, 400, 600);
assertThat(string.endsWith(ByteString.EMPTY)).isTrue();
assertThat(string.endsWith(string)).isTrue();
assertThat(string.endsWith(suffix)).isTrue();
assertThat(string.endsWith(prefix)).isFalse();
assertThat(suffix.endsWith(prefix)).isFalse();
assertThat(prefix.endsWith(suffix)).isFalse();
assertThat(ByteString.EMPTY.endsWith(suffix)).isFalse();
assertThat(ByteString.EMPTY.endsWith(ByteString.EMPTY)).isTrue();
}
static List<ByteString> makeConcretePieces(byte[] referenceBytes) {
List<ByteString> pieces = new ArrayList<ByteString>();
// Starting length should be small enough that we'll do some concatenating by
// copying if we just concatenate all these pieces together.
for (int start = 0, length = 16; start < referenceBytes.length; start += length) {
length = (length << 1) - 1;
if (start + length > referenceBytes.length) {
length = referenceBytes.length - start;
}
pieces.add(ByteString.copyFrom(referenceBytes, start, length));
}
return pieces;
}
private byte[] substringUsingWriteTo(ByteString data, int offset, int length) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
data.writeTo(output, offset, length);
return output.toByteArray();
}
@Test
public void testWriteToOutputStream() throws Exception {
// Choose a size large enough so when two ByteStrings are concatenated they
// won't be merged into one byte array due to some optimizations.
final int dataSize = ByteString.CONCATENATE_BY_COPY_SIZE + 1;
byte[] data1 = new byte[dataSize];
Arrays.fill(data1, (byte) 1);
data1[1] = (byte) 11;
// Test LiteralByteString.writeTo(OutputStream,int,int)
ByteString left = ByteString.wrap(data1);
byte[] result = substringUsingWriteTo(left, 1, 1);
assertThat(result).hasLength(1);
assertThat(result[0]).isEqualTo((byte) 11);
byte[] data2 = new byte[dataSize];
Arrays.fill(data2, 0, data1.length, (byte) 2);
ByteString right = ByteString.wrap(data2);
// Concatenate two ByteStrings to create a RopeByteString.
ByteString root = left.concat(right);
// Make sure we are actually testing a RopeByteString with a simple tree
// structure.
assertThat(root.getTreeDepth()).isEqualTo(1);
// Write parts of the left node.
result = substringUsingWriteTo(root, 0, dataSize);
assertThat(result).hasLength(dataSize);
assertThat(result[0]).isEqualTo((byte) 1);
assertThat(result[dataSize - 1]).isEqualTo((byte) 1);
// Write parts of the right node.
result = substringUsingWriteTo(root, dataSize, dataSize);
assertThat(result).hasLength(dataSize);
assertThat(result[0]).isEqualTo((byte) 2);
assertThat(result[dataSize - 1]).isEqualTo((byte) 2);
// Write a segment of bytes that runs across both nodes.
result = substringUsingWriteTo(root, dataSize / 2, dataSize);
assertThat(result).hasLength(dataSize);
assertThat(result[0]).isEqualTo((byte) 1);
assertThat(result[dataSize - dataSize / 2 - 1]).isEqualTo((byte) 1);
assertThat(result[dataSize - dataSize / 2]).isEqualTo((byte) 2);
assertThat(result[dataSize - 1]).isEqualTo((byte) 2);
}
/** Tests ByteString uses Arrays based byte copier when running under Hotstop VM. */
@Test
public void testByteArrayCopier() throws Exception {
if (Android.isOnAndroidDevice()) {
return;
}
Field field = ByteString.class.getDeclaredField("byteArrayCopier");
field.setAccessible(true);
Object byteArrayCopier = field.get(null);
assertThat(byteArrayCopier).isNotNull();
assertWithMessage(byteArrayCopier.toString())
.that(byteArrayCopier.getClass().getSimpleName().endsWith("ArraysByteArrayCopier"))
.isTrue();
}
}
|
googleapis/google-cloud-java | 36,268 | java-netapp/proto-google-cloud-netapp-v1/src/main/java/com/google/cloud/netapp/v1/CreateBackupRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/netapp/v1/backup.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.netapp.v1;
/**
*
*
* <pre>
* CreateBackupRequest creates a backup.
* </pre>
*
* Protobuf type {@code google.cloud.netapp.v1.CreateBackupRequest}
*/
public final class CreateBackupRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.netapp.v1.CreateBackupRequest)
CreateBackupRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use CreateBackupRequest.newBuilder() to construct.
private CreateBackupRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private CreateBackupRequest() {
parent_ = "";
backupId_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new CreateBackupRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.netapp.v1.BackupProto
.internal_static_google_cloud_netapp_v1_CreateBackupRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.netapp.v1.BackupProto
.internal_static_google_cloud_netapp_v1_CreateBackupRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.netapp.v1.CreateBackupRequest.class,
com.google.cloud.netapp.v1.CreateBackupRequest.Builder.class);
}
private int bitField0_;
public static final int PARENT_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The NetApp backupVault to create the backups of, in the format
* `projects/*/locations/*/backupVaults/{backup_vault_id}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The NetApp backupVault to create the backups of, in the format
* `projects/*/locations/*/backupVaults/{backup_vault_id}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int BACKUP_ID_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object backupId_ = "";
/**
*
*
* <pre>
* Required. The ID to use for the backup.
* The ID must be unique within the specified backupVault.
* Must contain only letters, numbers and hyphen, with the first
* character a letter, the last a letter or a
* number, and a 63 character maximum.
* </pre>
*
* <code>string backup_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The backupId.
*/
@java.lang.Override
public java.lang.String getBackupId() {
java.lang.Object ref = backupId_;
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();
backupId_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The ID to use for the backup.
* The ID must be unique within the specified backupVault.
* Must contain only letters, numbers and hyphen, with the first
* character a letter, the last a letter or a
* number, and a 63 character maximum.
* </pre>
*
* <code>string backup_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for backupId.
*/
@java.lang.Override
public com.google.protobuf.ByteString getBackupIdBytes() {
java.lang.Object ref = backupId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
backupId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int BACKUP_FIELD_NUMBER = 3;
private com.google.cloud.netapp.v1.Backup backup_;
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the backup field is set.
*/
@java.lang.Override
public boolean hasBackup() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The backup.
*/
@java.lang.Override
public com.google.cloud.netapp.v1.Backup getBackup() {
return backup_ == null ? com.google.cloud.netapp.v1.Backup.getDefaultInstance() : backup_;
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.netapp.v1.BackupOrBuilder getBackupOrBuilder() {
return backup_ == null ? com.google.cloud.netapp.v1.Backup.getDefaultInstance() : backup_;
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backupId_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, backupId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
output.writeMessage(3, getBackup());
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backupId_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, backupId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getBackup());
}
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.netapp.v1.CreateBackupRequest)) {
return super.equals(obj);
}
com.google.cloud.netapp.v1.CreateBackupRequest other =
(com.google.cloud.netapp.v1.CreateBackupRequest) obj;
if (!getParent().equals(other.getParent())) return false;
if (!getBackupId().equals(other.getBackupId())) return false;
if (hasBackup() != other.hasBackup()) return false;
if (hasBackup()) {
if (!getBackup().equals(other.getBackup())) 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();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
hash = (37 * hash) + BACKUP_ID_FIELD_NUMBER;
hash = (53 * hash) + getBackupId().hashCode();
if (hasBackup()) {
hash = (37 * hash) + BACKUP_FIELD_NUMBER;
hash = (53 * hash) + getBackup().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.netapp.v1.CreateBackupRequest parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.netapp.v1.CreateBackupRequest 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.netapp.v1.CreateBackupRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.netapp.v1.CreateBackupRequest 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.netapp.v1.CreateBackupRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.netapp.v1.CreateBackupRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.netapp.v1.CreateBackupRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.netapp.v1.CreateBackupRequest 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.netapp.v1.CreateBackupRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.netapp.v1.CreateBackupRequest 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.netapp.v1.CreateBackupRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.netapp.v1.CreateBackupRequest 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.netapp.v1.CreateBackupRequest 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;
}
/**
*
*
* <pre>
* CreateBackupRequest creates a backup.
* </pre>
*
* Protobuf type {@code google.cloud.netapp.v1.CreateBackupRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.netapp.v1.CreateBackupRequest)
com.google.cloud.netapp.v1.CreateBackupRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.netapp.v1.BackupProto
.internal_static_google_cloud_netapp_v1_CreateBackupRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.netapp.v1.BackupProto
.internal_static_google_cloud_netapp_v1_CreateBackupRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.netapp.v1.CreateBackupRequest.class,
com.google.cloud.netapp.v1.CreateBackupRequest.Builder.class);
}
// Construct using com.google.cloud.netapp.v1.CreateBackupRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getBackupFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
parent_ = "";
backupId_ = "";
backup_ = null;
if (backupBuilder_ != null) {
backupBuilder_.dispose();
backupBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.netapp.v1.BackupProto
.internal_static_google_cloud_netapp_v1_CreateBackupRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.netapp.v1.CreateBackupRequest getDefaultInstanceForType() {
return com.google.cloud.netapp.v1.CreateBackupRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.netapp.v1.CreateBackupRequest build() {
com.google.cloud.netapp.v1.CreateBackupRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.netapp.v1.CreateBackupRequest buildPartial() {
com.google.cloud.netapp.v1.CreateBackupRequest result =
new com.google.cloud.netapp.v1.CreateBackupRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.netapp.v1.CreateBackupRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.parent_ = parent_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.backupId_ = backupId_;
}
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000004) != 0)) {
result.backup_ = backupBuilder_ == null ? backup_ : backupBuilder_.build();
to_bitField0_ |= 0x00000001;
}
result.bitField0_ |= to_bitField0_;
}
@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.netapp.v1.CreateBackupRequest) {
return mergeFrom((com.google.cloud.netapp.v1.CreateBackupRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.netapp.v1.CreateBackupRequest other) {
if (other == com.google.cloud.netapp.v1.CreateBackupRequest.getDefaultInstance()) return this;
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getBackupId().isEmpty()) {
backupId_ = other.backupId_;
bitField0_ |= 0x00000002;
onChanged();
}
if (other.hasBackup()) {
mergeBackup(other.getBackup());
}
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 10:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
backupId_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 26:
{
input.readMessage(getBackupFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000004;
break;
} // case 26
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.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The NetApp backupVault to create the backups of, in the format
* `projects/*/locations/*/backupVaults/{backup_vault_id}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The NetApp backupVault to create the backups of, in the format
* `projects/*/locations/*/backupVaults/{backup_vault_id}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The NetApp backupVault to create the backups of, in the format
* `projects/*/locations/*/backupVaults/{backup_vault_id}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The NetApp backupVault to create the backups of, in the format
* `projects/*/locations/*/backupVaults/{backup_vault_id}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The NetApp backupVault to create the backups of, in the format
* `projects/*/locations/*/backupVaults/{backup_vault_id}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object backupId_ = "";
/**
*
*
* <pre>
* Required. The ID to use for the backup.
* The ID must be unique within the specified backupVault.
* Must contain only letters, numbers and hyphen, with the first
* character a letter, the last a letter or a
* number, and a 63 character maximum.
* </pre>
*
* <code>string backup_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The backupId.
*/
public java.lang.String getBackupId() {
java.lang.Object ref = backupId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
backupId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The ID to use for the backup.
* The ID must be unique within the specified backupVault.
* Must contain only letters, numbers and hyphen, with the first
* character a letter, the last a letter or a
* number, and a 63 character maximum.
* </pre>
*
* <code>string backup_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for backupId.
*/
public com.google.protobuf.ByteString getBackupIdBytes() {
java.lang.Object ref = backupId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
backupId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The ID to use for the backup.
* The ID must be unique within the specified backupVault.
* Must contain only letters, numbers and hyphen, with the first
* character a letter, the last a letter or a
* number, and a 63 character maximum.
* </pre>
*
* <code>string backup_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The backupId to set.
* @return This builder for chaining.
*/
public Builder setBackupId(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
backupId_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The ID to use for the backup.
* The ID must be unique within the specified backupVault.
* Must contain only letters, numbers and hyphen, with the first
* character a letter, the last a letter or a
* number, and a 63 character maximum.
* </pre>
*
* <code>string backup_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return This builder for chaining.
*/
public Builder clearBackupId() {
backupId_ = getDefaultInstance().getBackupId();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The ID to use for the backup.
* The ID must be unique within the specified backupVault.
* Must contain only letters, numbers and hyphen, with the first
* character a letter, the last a letter or a
* number, and a 63 character maximum.
* </pre>
*
* <code>string backup_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The bytes for backupId to set.
* @return This builder for chaining.
*/
public Builder setBackupIdBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
backupId_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private com.google.cloud.netapp.v1.Backup backup_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.netapp.v1.Backup,
com.google.cloud.netapp.v1.Backup.Builder,
com.google.cloud.netapp.v1.BackupOrBuilder>
backupBuilder_;
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the backup field is set.
*/
public boolean hasBackup() {
return ((bitField0_ & 0x00000004) != 0);
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The backup.
*/
public com.google.cloud.netapp.v1.Backup getBackup() {
if (backupBuilder_ == null) {
return backup_ == null ? com.google.cloud.netapp.v1.Backup.getDefaultInstance() : backup_;
} else {
return backupBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setBackup(com.google.cloud.netapp.v1.Backup value) {
if (backupBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
backup_ = value;
} else {
backupBuilder_.setMessage(value);
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setBackup(com.google.cloud.netapp.v1.Backup.Builder builderForValue) {
if (backupBuilder_ == null) {
backup_ = builderForValue.build();
} else {
backupBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeBackup(com.google.cloud.netapp.v1.Backup value) {
if (backupBuilder_ == null) {
if (((bitField0_ & 0x00000004) != 0)
&& backup_ != null
&& backup_ != com.google.cloud.netapp.v1.Backup.getDefaultInstance()) {
getBackupBuilder().mergeFrom(value);
} else {
backup_ = value;
}
} else {
backupBuilder_.mergeFrom(value);
}
if (backup_ != null) {
bitField0_ |= 0x00000004;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearBackup() {
bitField0_ = (bitField0_ & ~0x00000004);
backup_ = null;
if (backupBuilder_ != null) {
backupBuilder_.dispose();
backupBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.netapp.v1.Backup.Builder getBackupBuilder() {
bitField0_ |= 0x00000004;
onChanged();
return getBackupFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.netapp.v1.BackupOrBuilder getBackupOrBuilder() {
if (backupBuilder_ != null) {
return backupBuilder_.getMessageOrBuilder();
} else {
return backup_ == null ? com.google.cloud.netapp.v1.Backup.getDefaultInstance() : backup_;
}
}
/**
*
*
* <pre>
* Required. A backup resource
* </pre>
*
* <code>.google.cloud.netapp.v1.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.netapp.v1.Backup,
com.google.cloud.netapp.v1.Backup.Builder,
com.google.cloud.netapp.v1.BackupOrBuilder>
getBackupFieldBuilder() {
if (backupBuilder_ == null) {
backupBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.netapp.v1.Backup,
com.google.cloud.netapp.v1.Backup.Builder,
com.google.cloud.netapp.v1.BackupOrBuilder>(
getBackup(), getParentForChildren(), isClean());
backup_ = null;
}
return backupBuilder_;
}
@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.netapp.v1.CreateBackupRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.netapp.v1.CreateBackupRequest)
private static final com.google.cloud.netapp.v1.CreateBackupRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.netapp.v1.CreateBackupRequest();
}
public static com.google.cloud.netapp.v1.CreateBackupRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<CreateBackupRequest> PARSER =
new com.google.protobuf.AbstractParser<CreateBackupRequest>() {
@java.lang.Override
public CreateBackupRequest 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<CreateBackupRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<CreateBackupRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.netapp.v1.CreateBackupRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,460 | java-dialogflow/grpc-google-cloud-dialogflow-v2beta1/src/main/java/com/google/cloud/dialogflow/v2beta1/SipTrunksGrpc.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.dialogflow.v2beta1;
import static io.grpc.MethodDescriptor.generateFullMethodName;
/**
*
*
* <pre>
* Service for managing [SipTrunks][google.cloud.dialogflow.v2beta1.SipTrunk].
* </pre>
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler",
comments = "Source: google/cloud/dialogflow/v2beta1/sip_trunk.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class SipTrunksGrpc {
private SipTrunksGrpc() {}
public static final java.lang.String SERVICE_NAME = "google.cloud.dialogflow.v2beta1.SipTrunks";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getCreateSipTrunkMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "CreateSipTrunk",
requestType = com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest.class,
responseType = com.google.cloud.dialogflow.v2beta1.SipTrunk.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getCreateSipTrunkMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getCreateSipTrunkMethod;
if ((getCreateSipTrunkMethod = SipTrunksGrpc.getCreateSipTrunkMethod) == null) {
synchronized (SipTrunksGrpc.class) {
if ((getCreateSipTrunkMethod = SipTrunksGrpc.getCreateSipTrunkMethod) == null) {
SipTrunksGrpc.getCreateSipTrunkMethod =
getCreateSipTrunkMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateSipTrunk"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.SipTrunk.getDefaultInstance()))
.setSchemaDescriptor(new SipTrunksMethodDescriptorSupplier("CreateSipTrunk"))
.build();
}
}
}
return getCreateSipTrunkMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest, com.google.protobuf.Empty>
getDeleteSipTrunkMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "DeleteSipTrunk",
requestType = com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest.class,
responseType = com.google.protobuf.Empty.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest, com.google.protobuf.Empty>
getDeleteSipTrunkMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest, com.google.protobuf.Empty>
getDeleteSipTrunkMethod;
if ((getDeleteSipTrunkMethod = SipTrunksGrpc.getDeleteSipTrunkMethod) == null) {
synchronized (SipTrunksGrpc.class) {
if ((getDeleteSipTrunkMethod = SipTrunksGrpc.getDeleteSipTrunkMethod) == null) {
SipTrunksGrpc.getDeleteSipTrunkMethod =
getDeleteSipTrunkMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest,
com.google.protobuf.Empty>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteSipTrunk"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.protobuf.Empty.getDefaultInstance()))
.setSchemaDescriptor(new SipTrunksMethodDescriptorSupplier("DeleteSipTrunk"))
.build();
}
}
}
return getDeleteSipTrunkMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest,
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>
getListSipTrunksMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "ListSipTrunks",
requestType = com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest.class,
responseType = com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest,
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>
getListSipTrunksMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest,
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>
getListSipTrunksMethod;
if ((getListSipTrunksMethod = SipTrunksGrpc.getListSipTrunksMethod) == null) {
synchronized (SipTrunksGrpc.class) {
if ((getListSipTrunksMethod = SipTrunksGrpc.getListSipTrunksMethod) == null) {
SipTrunksGrpc.getListSipTrunksMethod =
getListSipTrunksMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest,
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListSipTrunks"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse
.getDefaultInstance()))
.setSchemaDescriptor(new SipTrunksMethodDescriptorSupplier("ListSipTrunks"))
.build();
}
}
}
return getListSipTrunksMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getGetSipTrunkMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "GetSipTrunk",
requestType = com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest.class,
responseType = com.google.cloud.dialogflow.v2beta1.SipTrunk.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getGetSipTrunkMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getGetSipTrunkMethod;
if ((getGetSipTrunkMethod = SipTrunksGrpc.getGetSipTrunkMethod) == null) {
synchronized (SipTrunksGrpc.class) {
if ((getGetSipTrunkMethod = SipTrunksGrpc.getGetSipTrunkMethod) == null) {
SipTrunksGrpc.getGetSipTrunkMethod =
getGetSipTrunkMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetSipTrunk"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.SipTrunk.getDefaultInstance()))
.setSchemaDescriptor(new SipTrunksMethodDescriptorSupplier("GetSipTrunk"))
.build();
}
}
}
return getGetSipTrunkMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getUpdateSipTrunkMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "UpdateSipTrunk",
requestType = com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest.class,
responseType = com.google.cloud.dialogflow.v2beta1.SipTrunk.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getUpdateSipTrunkMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getUpdateSipTrunkMethod;
if ((getUpdateSipTrunkMethod = SipTrunksGrpc.getUpdateSipTrunkMethod) == null) {
synchronized (SipTrunksGrpc.class) {
if ((getUpdateSipTrunkMethod = SipTrunksGrpc.getUpdateSipTrunkMethod) == null) {
SipTrunksGrpc.getUpdateSipTrunkMethod =
getUpdateSipTrunkMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdateSipTrunk"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.dialogflow.v2beta1.SipTrunk.getDefaultInstance()))
.setSchemaDescriptor(new SipTrunksMethodDescriptorSupplier("UpdateSipTrunk"))
.build();
}
}
}
return getUpdateSipTrunkMethod;
}
/** Creates a new async stub that supports all call types for the service */
public static SipTrunksStub newStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SipTrunksStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SipTrunksStub>() {
@java.lang.Override
public SipTrunksStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksStub(channel, callOptions);
}
};
return SipTrunksStub.newStub(factory, channel);
}
/** Creates a new blocking-style stub that supports all types of calls on the service */
public static SipTrunksBlockingV2Stub newBlockingV2Stub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SipTrunksBlockingV2Stub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SipTrunksBlockingV2Stub>() {
@java.lang.Override
public SipTrunksBlockingV2Stub newStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksBlockingV2Stub(channel, callOptions);
}
};
return SipTrunksBlockingV2Stub.newStub(factory, channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static SipTrunksBlockingStub newBlockingStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SipTrunksBlockingStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SipTrunksBlockingStub>() {
@java.lang.Override
public SipTrunksBlockingStub newStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksBlockingStub(channel, callOptions);
}
};
return SipTrunksBlockingStub.newStub(factory, channel);
}
/** Creates a new ListenableFuture-style stub that supports unary calls on the service */
public static SipTrunksFutureStub newFutureStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SipTrunksFutureStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SipTrunksFutureStub>() {
@java.lang.Override
public SipTrunksFutureStub newStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksFutureStub(channel, callOptions);
}
};
return SipTrunksFutureStub.newStub(factory, channel);
}
/**
*
*
* <pre>
* Service for managing [SipTrunks][google.cloud.dialogflow.v2beta1.SipTrunk].
* </pre>
*/
public interface AsyncService {
/**
*
*
* <pre>
* Creates a SipTrunk for a specified location.
* </pre>
*/
default void createSipTrunk(
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>
responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getCreateSipTrunkMethod(), responseObserver);
}
/**
*
*
* <pre>
* Deletes a specified SipTrunk.
* </pre>
*/
default void deleteSipTrunk(
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getDeleteSipTrunkMethod(), responseObserver);
}
/**
*
*
* <pre>
* Returns a list of SipTrunks in the specified location.
* </pre>
*/
default void listSipTrunks(
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>
responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getListSipTrunksMethod(), responseObserver);
}
/**
*
*
* <pre>
* Retrieves the specified SipTrunk.
* </pre>
*/
default void getSipTrunk(
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>
responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getGetSipTrunkMethod(), responseObserver);
}
/**
*
*
* <pre>
* Updates the specified SipTrunk.
* </pre>
*/
default void updateSipTrunk(
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>
responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getUpdateSipTrunkMethod(), responseObserver);
}
}
/**
* Base class for the server implementation of the service SipTrunks.
*
* <pre>
* Service for managing [SipTrunks][google.cloud.dialogflow.v2beta1.SipTrunk].
* </pre>
*/
public abstract static class SipTrunksImplBase implements io.grpc.BindableService, AsyncService {
@java.lang.Override
public final io.grpc.ServerServiceDefinition bindService() {
return SipTrunksGrpc.bindService(this);
}
}
/**
* A stub to allow clients to do asynchronous rpc calls to service SipTrunks.
*
* <pre>
* Service for managing [SipTrunks][google.cloud.dialogflow.v2beta1.SipTrunk].
* </pre>
*/
public static final class SipTrunksStub extends io.grpc.stub.AbstractAsyncStub<SipTrunksStub> {
private SipTrunksStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SipTrunksStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksStub(channel, callOptions);
}
/**
*
*
* <pre>
* Creates a SipTrunk for a specified location.
* </pre>
*/
public void createSipTrunk(
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>
responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getCreateSipTrunkMethod(), getCallOptions()),
request,
responseObserver);
}
/**
*
*
* <pre>
* Deletes a specified SipTrunk.
* </pre>
*/
public void deleteSipTrunk(
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getDeleteSipTrunkMethod(), getCallOptions()),
request,
responseObserver);
}
/**
*
*
* <pre>
* Returns a list of SipTrunks in the specified location.
* </pre>
*/
public void listSipTrunks(
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>
responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getListSipTrunksMethod(), getCallOptions()),
request,
responseObserver);
}
/**
*
*
* <pre>
* Retrieves the specified SipTrunk.
* </pre>
*/
public void getSipTrunk(
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>
responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getGetSipTrunkMethod(), getCallOptions()),
request,
responseObserver);
}
/**
*
*
* <pre>
* Updates the specified SipTrunk.
* </pre>
*/
public void updateSipTrunk(
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>
responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getUpdateSipTrunkMethod(), getCallOptions()),
request,
responseObserver);
}
}
/**
* A stub to allow clients to do synchronous rpc calls to service SipTrunks.
*
* <pre>
* Service for managing [SipTrunks][google.cloud.dialogflow.v2beta1.SipTrunk].
* </pre>
*/
public static final class SipTrunksBlockingV2Stub
extends io.grpc.stub.AbstractBlockingStub<SipTrunksBlockingV2Stub> {
private SipTrunksBlockingV2Stub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SipTrunksBlockingV2Stub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksBlockingV2Stub(channel, callOptions);
}
/**
*
*
* <pre>
* Creates a SipTrunk for a specified location.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.SipTrunk createSipTrunk(
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getCreateSipTrunkMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Deletes a specified SipTrunk.
* </pre>
*/
public com.google.protobuf.Empty deleteSipTrunk(
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getDeleteSipTrunkMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Returns a list of SipTrunks in the specified location.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse listSipTrunks(
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getListSipTrunksMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Retrieves the specified SipTrunk.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.SipTrunk getSipTrunk(
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getGetSipTrunkMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Updates the specified SipTrunk.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.SipTrunk updateSipTrunk(
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getUpdateSipTrunkMethod(), getCallOptions(), request);
}
}
/**
* A stub to allow clients to do limited synchronous rpc calls to service SipTrunks.
*
* <pre>
* Service for managing [SipTrunks][google.cloud.dialogflow.v2beta1.SipTrunk].
* </pre>
*/
public static final class SipTrunksBlockingStub
extends io.grpc.stub.AbstractBlockingStub<SipTrunksBlockingStub> {
private SipTrunksBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SipTrunksBlockingStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksBlockingStub(channel, callOptions);
}
/**
*
*
* <pre>
* Creates a SipTrunk for a specified location.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.SipTrunk createSipTrunk(
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getCreateSipTrunkMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Deletes a specified SipTrunk.
* </pre>
*/
public com.google.protobuf.Empty deleteSipTrunk(
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getDeleteSipTrunkMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Returns a list of SipTrunks in the specified location.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse listSipTrunks(
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getListSipTrunksMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Retrieves the specified SipTrunk.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.SipTrunk getSipTrunk(
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getGetSipTrunkMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Updates the specified SipTrunk.
* </pre>
*/
public com.google.cloud.dialogflow.v2beta1.SipTrunk updateSipTrunk(
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getUpdateSipTrunkMethod(), getCallOptions(), request);
}
}
/**
* A stub to allow clients to do ListenableFuture-style rpc calls to service SipTrunks.
*
* <pre>
* Service for managing [SipTrunks][google.cloud.dialogflow.v2beta1.SipTrunk].
* </pre>
*/
public static final class SipTrunksFutureStub
extends io.grpc.stub.AbstractFutureStub<SipTrunksFutureStub> {
private SipTrunksFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SipTrunksFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SipTrunksFutureStub(channel, callOptions);
}
/**
*
*
* <pre>
* Creates a SipTrunk for a specified location.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<
com.google.cloud.dialogflow.v2beta1.SipTrunk>
createSipTrunk(com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getCreateSipTrunkMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Deletes a specified SipTrunk.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.Empty>
deleteSipTrunk(com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getDeleteSipTrunkMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Returns a list of SipTrunks in the specified location.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>
listSipTrunks(com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getListSipTrunksMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Retrieves the specified SipTrunk.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<
com.google.cloud.dialogflow.v2beta1.SipTrunk>
getSipTrunk(com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getGetSipTrunkMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Updates the specified SipTrunk.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<
com.google.cloud.dialogflow.v2beta1.SipTrunk>
updateSipTrunk(com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getUpdateSipTrunkMethod(), getCallOptions()), request);
}
}
private static final int METHODID_CREATE_SIP_TRUNK = 0;
private static final int METHODID_DELETE_SIP_TRUNK = 1;
private static final int METHODID_LIST_SIP_TRUNKS = 2;
private static final int METHODID_GET_SIP_TRUNK = 3;
private static final int METHODID_UPDATE_SIP_TRUNK = 4;
private static final class MethodHandlers<Req, Resp>
implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final AsyncService serviceImpl;
private final int methodId;
MethodHandlers(AsyncService serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_CREATE_SIP_TRUNK:
serviceImpl.createSipTrunk(
(com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest) request,
(io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>)
responseObserver);
break;
case METHODID_DELETE_SIP_TRUNK:
serviceImpl.deleteSipTrunk(
(com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest) request,
(io.grpc.stub.StreamObserver<com.google.protobuf.Empty>) responseObserver);
break;
case METHODID_LIST_SIP_TRUNKS:
serviceImpl.listSipTrunks(
(com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest) request,
(io.grpc.stub.StreamObserver<
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>)
responseObserver);
break;
case METHODID_GET_SIP_TRUNK:
serviceImpl.getSipTrunk(
(com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest) request,
(io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>)
responseObserver);
break;
case METHODID_UPDATE_SIP_TRUNK:
serviceImpl.updateSipTrunk(
(com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest) request,
(io.grpc.stub.StreamObserver<com.google.cloud.dialogflow.v2beta1.SipTrunk>)
responseObserver);
break;
default:
throw new AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
}
public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getCreateSipTrunkMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.dialogflow.v2beta1.CreateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>(
service, METHODID_CREATE_SIP_TRUNK)))
.addMethod(
getDeleteSipTrunkMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.dialogflow.v2beta1.DeleteSipTrunkRequest,
com.google.protobuf.Empty>(service, METHODID_DELETE_SIP_TRUNK)))
.addMethod(
getListSipTrunksMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.dialogflow.v2beta1.ListSipTrunksRequest,
com.google.cloud.dialogflow.v2beta1.ListSipTrunksResponse>(
service, METHODID_LIST_SIP_TRUNKS)))
.addMethod(
getGetSipTrunkMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.dialogflow.v2beta1.GetSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>(service, METHODID_GET_SIP_TRUNK)))
.addMethod(
getUpdateSipTrunkMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.dialogflow.v2beta1.UpdateSipTrunkRequest,
com.google.cloud.dialogflow.v2beta1.SipTrunk>(
service, METHODID_UPDATE_SIP_TRUNK)))
.build();
}
private abstract static class SipTrunksBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier,
io.grpc.protobuf.ProtoServiceDescriptorSupplier {
SipTrunksBaseDescriptorSupplier() {}
@java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return com.google.cloud.dialogflow.v2beta1.SipTrunkProto.getDescriptor();
}
@java.lang.Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("SipTrunks");
}
}
private static final class SipTrunksFileDescriptorSupplier
extends SipTrunksBaseDescriptorSupplier {
SipTrunksFileDescriptorSupplier() {}
}
private static final class SipTrunksMethodDescriptorSupplier
extends SipTrunksBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final java.lang.String methodName;
SipTrunksMethodDescriptorSupplier(java.lang.String methodName) {
this.methodName = methodName;
}
@java.lang.Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (SipTrunksGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor =
result =
io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new SipTrunksFileDescriptorSupplier())
.addMethod(getCreateSipTrunkMethod())
.addMethod(getDeleteSipTrunkMethod())
.addMethod(getListSipTrunksMethod())
.addMethod(getGetSipTrunkMethod())
.addMethod(getUpdateSipTrunkMethod())
.build();
}
}
}
return result;
}
}
|
apache/hadoop | 36,176 | hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/contract/AbstractContractDistCpTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.tools.contract;
import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_LOGGING_LEVEL_INFO;
import static org.apache.hadoop.fs.contract.ContractTestUtils.*;
import static org.apache.hadoop.fs.statistics.IOStatisticsLogging.logIOStatisticsAtLevel;
import static org.apache.hadoop.tools.DistCpConstants.CONF_LABEL_DISTCP_JOB_ID;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.fs.contract.AbstractFSContractTestBase;
import org.apache.hadoop.fs.contract.ContractTestUtils;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.TestName;
import org.apache.hadoop.tools.CopyListingFileStatus;
import org.apache.hadoop.tools.DistCp;
import org.apache.hadoop.tools.DistCpConstants;
import org.apache.hadoop.tools.DistCpOptions;
import org.apache.hadoop.tools.SimpleCopyListing;
import org.apache.hadoop.tools.mapred.CopyMapper;
import org.apache.hadoop.tools.util.DistCpTestUtils;
import org.apache.hadoop.util.functional.RemoteIterators;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Contract test suite covering a file system's integration with DistCp. The
* tests coordinate two file system instances: one "local", which is the local
* file system, and the other "remote", which is the file system implementation
* under test. The tests in the suite cover both copying from local to remote
* (e.g. a backup use case) and copying from remote to local (e.g. a restore use
* case).
* The HDFS contract test needs to be run explicitly.
*/
public abstract class AbstractContractDistCpTest
extends AbstractFSContractTestBase {
private static final Logger LOG =
LoggerFactory.getLogger(AbstractContractDistCpTest.class);
/** Using offset to change modification time in tests. */
private static final long MODIFICATION_TIME_OFFSET = 10000;
public static final String SCALE_TEST_DISTCP_FILE_SIZE_KB
= "scale.test.distcp.file.size.kb";
public static final int DEFAULT_DISTCP_SIZE_KB = 1024;
protected static final int MB = 1024 * 1024;
/**
* Default depth for a directory tree: {@value}.
*/
protected static final int DEFAULT_DEPTH = 3;
/**
* Default width for a directory tree: {@value}.
* Total dir size is
* <pre>
* DEFAULT_WITH^DEFAULT_DEPTH
* </pre>
* So the duration of a test run grows rapidly with this value.
* This has very significant consequences for object storage runs.
*/
protected static final int DEFAULT_WIDTH = 2;
@RegisterExtension
public TestName testName = new TestName();
/**
* The timeout value is extended over the default so that large updates
* are allowed to take time, especially to remote stores.
* @return the current test timeout
*/
protected int getTestTimeoutMillis() {
return 15 * 60 * 1000;
}
private Configuration conf;
private FileSystem localFS, remoteFS;
private Path localDir, remoteDir;
private Path inputDir;
private Path inputSubDir1;
private Path inputSubDir2;
private Path inputSubDir4;
private Path inputFile1;
private Path inputFile2;
private Path inputFile3;
private Path inputFile4;
private Path inputFile5;
private Path outputDir;
private Path outputSubDir1;
private Path outputSubDir2;
private Path outputSubDir4;
private Path outputFile1;
private Path outputFile2;
private Path outputFile3;
private Path outputFile4;
private Path outputFile5;
private Path inputDirUnderOutputDir;
@Override
protected Configuration createConfiguration() {
Configuration newConf = new Configuration();
newConf.set("mapred.job.tracker", "local");
return newConf;
}
@BeforeEach
@Override
public void setup() throws Exception {
super.setup();
conf = getContract().getConf();
localFS = FileSystem.getLocal(conf);
remoteFS = getFileSystem();
// Test paths are isolated by concrete subclass name and test method name.
// All paths are fully qualified including scheme (not taking advantage of
// default file system), so if something fails, the messages will make it
// clear which paths are local and which paths are remote.
String className = getClass().getSimpleName();
String testSubDir = className + "/" + testName.getMethodName();
localDir =
localFS.makeQualified(new Path(new Path(
GenericTestUtils.getTestDir().toURI()), testSubDir + "/local"));
localFS.delete(localDir, true);
mkdirs(localFS, localDir);
Path testSubPath = path(testSubDir);
remoteDir = new Path(testSubPath, "remote");
// test teardown does this, but IDE-based test debugging can skip
// that teardown; this guarantees the initial state is clean
remoteFS.delete(remoteDir, true);
}
@Override
public void teardown() throws Exception {
// if remote FS supports IOStatistics log it.
logIOStatisticsAtLevel(LOG, IOSTATISTICS_LOGGING_LEVEL_INFO, getRemoteFS());
super.teardown();
}
/**
* Set up both input and output fields.
* @param src source tree
* @param dest dest tree
*/
protected void initPathFields(final Path src, final Path dest) {
initInputFields(src);
initOutputFields(dest);
}
/**
* Output field setup.
* @param path path to set up
*/
protected void initOutputFields(final Path path) {
outputDir = new Path(path, "outputDir");
inputDirUnderOutputDir = new Path(outputDir, "inputDir");
outputFile1 = new Path(inputDirUnderOutputDir, "file1");
outputSubDir1 = new Path(inputDirUnderOutputDir, "subDir1");
outputFile2 = new Path(outputSubDir1, "file2");
outputSubDir2 = new Path(inputDirUnderOutputDir, "subDir2/subDir2");
outputFile3 = new Path(outputSubDir2, "file3");
outputSubDir4 = new Path(inputDirUnderOutputDir, "subDir4/subDir4");
outputFile4 = new Path(outputSubDir4, "file4");
outputFile5 = new Path(outputSubDir4, "file5");
}
/**
* this path setup is used across different methods (copy, update, track)
* so they are set up as fields.
* @param srcDir source directory for these to go under.
*/
protected void initInputFields(final Path srcDir) {
inputDir = new Path(srcDir, "inputDir");
inputFile1 = new Path(inputDir, "file1");
inputSubDir1 = new Path(inputDir, "subDir1");
inputFile2 = new Path(inputSubDir1, "file2");
inputSubDir2 = new Path(inputDir, "subDir2/subDir2");
inputFile3 = new Path(inputSubDir2, "file3");
inputSubDir4 = new Path(inputDir, "subDir4/subDir4");
inputFile4 = new Path(inputSubDir4, "file4");
inputFile5 = new Path(inputSubDir4, "file5");
}
protected FileSystem getLocalFS() {
return localFS;
}
protected FileSystem getRemoteFS() {
return remoteFS;
}
protected Path getLocalDir() {
return localDir;
}
protected Path getRemoteDir() {
return remoteDir;
}
@Test
public void testUpdateDeepDirectoryStructureToRemote() throws Exception {
describe("update a deep directory structure from local to remote");
distCpDeepDirectoryStructure(localFS, localDir, remoteFS, remoteDir);
distCpUpdateDeepDirectoryStructure(inputDirUnderOutputDir);
}
@Test
public void testUpdateDeepDirectoryStructureNoChange() throws Exception {
describe("update an unchanged directory structure"
+ " from local to remote; expect no copy");
Path target = distCpDeepDirectoryStructure(localFS, localDir, remoteFS,
remoteDir);
describe("\nExecuting Update\n");
Job job = distCpUpdate(localDir, target);
assertCounterInRange(job, CopyMapper.Counter.SKIP, 1, -1);
assertCounterInRange(job, CopyMapper.Counter.BYTESCOPIED, 0, 0);
}
/**
* Assert that a counter is in a range; min and max values are inclusive.
* @param job job to query
* @param counter counter to examine
* @param min min value, if negative "no minimum"
* @param max max value, if negative "no maximum"
* @throws IOException IO problem
*/
void assertCounterInRange(Job job, Enum<?> counter, long min, long max)
throws IOException {
Counter c = job.getCounters().findCounter(counter);
long value = c.getValue();
String description =
String.format("%s value %s", c.getDisplayName(), value, false);
if (min >= 0) {
assertTrue(value >= min, description + " too below minimum " + min);
}
if (max >= 0) {
assertTrue(value <= max, description + " above maximum " + max);
}
}
/**
* Do a distcp from the local source to the destination filesystem.
* This is executed as part of
* {@link #testUpdateDeepDirectoryStructureToRemote()}; it's designed to be
* overidden or wrapped by subclasses which wish to add more assertions.
*
* Life is complicated here by the way that the src/dest paths
* on a distcp is different with -update.
* @param destDir output directory used by the initial distcp
* @return the distcp job
*/
protected Job distCpUpdateDeepDirectoryStructure(final Path destDir)
throws Exception {
describe("Now do an incremental update with deletion of missing files");
Path srcDir = inputDir;
LOG.info("Source directory = {}, dest={}", srcDir, destDir);
ContractTestUtils.assertPathsExist(localFS,
"Paths for test are wrong",
inputFile1, inputFile2, inputFile3, inputFile4, inputFile5);
modifySourceDirectories();
Job job = distCpUpdate(srcDir, destDir);
Path outputFileNew1 = new Path(outputSubDir2, "newfile1");
lsR("Updated Remote", remoteFS, destDir);
ContractTestUtils.assertPathDoesNotExist(remoteFS,
" deleted from " + inputFile1, outputFile1);
ContractTestUtils.assertIsFile(remoteFS, outputFileNew1);
ContractTestUtils.assertPathsDoNotExist(remoteFS,
"DistCP should have deleted",
outputFile3, outputFile4, outputSubDir4);
assertCounterInRange(job, CopyMapper.Counter.COPY, 1, 1);
assertCounterInRange(job, CopyMapper.Counter.SKIP, 1, -1);
return job;
}
/**
* Run distcp -update srcDir destDir.
* @param srcDir local source directory
* @param destDir remote destination directory.
* @return the completed job
* @throws Exception any failure.
*/
private Job distCpUpdate(final Path srcDir, final Path destDir)
throws Exception {
describe("\nDistcp -update from " + srcDir + " to " + destDir);
lsR("Local to update", localFS, srcDir);
lsR("Remote before update", remoteFS, destDir);
return runDistCp(buildWithStandardOptions(
new DistCpOptions.Builder(
Collections.singletonList(srcDir), destDir)
.withDeleteMissing(true)
.withSyncFolder(true)
.withSkipCRC(true)
.withDirectWrite(shouldUseDirectWrite())
.withOverwrite(false)));
}
/**
* Run distcp -update srcDir destDir.
* @param srcDir local source directory
* @param destDir remote destination directory.
* @return the completed job
* @throws Exception any failure.
*/
private Job distCpUpdateWithFs(final Path srcDir, final Path destDir,
FileSystem sourceFs, FileSystem targetFs)
throws Exception {
describe("\nDistcp -update from " + srcDir + " to " + destDir);
lsR("Source Fs to update", sourceFs, srcDir);
lsR("Target Fs before update", targetFs, destDir);
return runDistCp(buildWithStandardOptions(
new DistCpOptions.Builder(
Collections.singletonList(srcDir), destDir)
.withDeleteMissing(true)
.withSyncFolder(true)
.withSkipCRC(false)
.withDirectWrite(shouldUseDirectWrite())
.withOverwrite(false)));
}
/**
* Update the source directories as various tests expect,
* including adding a new file.
* @return the path to the newly created file
* @throws IOException IO failure
*/
private Path modifySourceDirectories() throws IOException {
localFS.delete(inputFile1, false);
localFS.delete(inputFile3, false);
// delete all of subdir4, so input/output file 4 & 5 will go
localFS.delete(inputSubDir4, true);
// add one new file
Path inputFileNew1 = new Path(inputSubDir2, "newfile1");
ContractTestUtils.touch(localFS, inputFileNew1);
return inputFileNew1;
}
@Test
public void testTrackDeepDirectoryStructureToRemote() throws Exception {
describe("copy a deep directory structure from local to remote");
Path destDir = distCpDeepDirectoryStructure(localFS, localDir, remoteFS,
remoteDir);
ContractTestUtils.assertIsDirectory(remoteFS, destDir);
describe("Now do an incremental update and save of missing files");
Path srcDir = inputDir;
// same path setup as in deepDirectoryStructure()
Path trackDir = new Path(localDir, "trackDir");
describe("\nDirectories\n");
lsR("Local to update", localFS, srcDir);
lsR("Remote before update", remoteFS, destDir);
ContractTestUtils.assertPathsExist(localFS,
"Paths for test are wrong",
inputFile2, inputFile3, inputFile4, inputFile5);
Path inputFileNew1 = modifySourceDirectories();
// Distcp set to track but not delete
runDistCp(buildWithStandardOptions(
new DistCpOptions.Builder(
Collections.singletonList(srcDir),
inputDirUnderOutputDir)
.withTrackMissing(trackDir)
.withSyncFolder(true)
.withDirectWrite(shouldUseDirectWrite())
.withOverwrite(false)));
lsR("tracked udpate", remoteFS, destDir);
// new file went over
Path outputFileNew1 = new Path(outputSubDir2, "newfile1");
ContractTestUtils.assertIsFile(remoteFS, outputFileNew1);
ContractTestUtils.assertPathExists(localFS, "tracking directory",
trackDir);
// now read in the listings
Path sortedSourceListing = new Path(trackDir,
DistCpConstants.SOURCE_SORTED_FILE);
ContractTestUtils.assertIsFile(localFS, sortedSourceListing);
Path sortedTargetListing = new Path(trackDir,
DistCpConstants.TARGET_SORTED_FILE);
ContractTestUtils.assertIsFile(localFS, sortedTargetListing);
// deletion didn't happen
ContractTestUtils.assertPathsExist(remoteFS,
"DistCP should have retained",
outputFile2, outputFile3, outputFile4, outputSubDir4);
// now scan the table and see that things are there.
Map<String, Path> sourceFiles = new HashMap<>(10);
Map<String, Path> targetFiles = new HashMap<>(10);
try (SequenceFile.Reader sourceReader = new SequenceFile.Reader(conf,
SequenceFile.Reader.file(sortedSourceListing));
SequenceFile.Reader targetReader = new SequenceFile.Reader(conf,
SequenceFile.Reader.file(sortedTargetListing))) {
CopyListingFileStatus copyStatus = new CopyListingFileStatus();
Text name = new Text();
while(sourceReader.next(name, copyStatus)) {
String key = name.toString();
Path path = copyStatus.getPath();
LOG.info("{}: {}", key, path);
sourceFiles.put(key, path);
}
while(targetReader.next(name, copyStatus)) {
String key = name.toString();
Path path = copyStatus.getPath();
LOG.info("{}: {}", key, path);
targetFiles.put(name.toString(), copyStatus.getPath());
}
}
// look for the new file in both lists
assertTrue(sourceFiles.containsValue(inputFileNew1),
"No " + outputFileNew1 + " in source listing");
assertTrue(targetFiles.containsValue(outputFileNew1),
"No " + outputFileNew1 + " in target listing");
assertTrue(targetFiles.containsValue(outputSubDir4),
"No " + outputSubDir4 + " in target listing");
assertFalse(sourceFiles.containsValue(inputSubDir4),
"Found " + inputSubDir4 + " in source listing");
}
public void lsR(final String description,
final FileSystem fs,
final Path dir) throws IOException {
RemoteIterator<LocatedFileStatus> files = fs.listFiles(dir, true);
LOG.info("{}: {}:", description, dir);
StringBuilder sb = new StringBuilder();
while(files.hasNext()) {
LocatedFileStatus status = files.next();
sb.append(String.format(" %s; type=%s; length=%d",
status.getPath(),
status.isDirectory()? "dir" : "file",
status.getLen()));
}
LOG.info("{}", sb);
}
@Test
public void largeFilesToRemote() throws Exception {
describe("copy multiple large files from local to remote");
largeFiles(localFS, localDir, remoteFS, remoteDir);
}
@Test
public void testDeepDirectoryStructureFromRemote() throws Exception {
describe("copy a deep directory structure from remote to local");
distCpDeepDirectoryStructure(remoteFS, remoteDir, localFS, localDir);
}
@Test
public void testLargeFilesFromRemote() throws Exception {
describe("copy multiple large files from remote to local");
largeFiles(remoteFS, remoteDir, localFS, localDir);
}
@Test
public void testSetJobId() throws Exception {
describe("check jobId is set in the conf");
remoteFS.create(new Path(remoteDir, "file1")).close();
DistCpTestUtils
.assertRunDistCp(DistCpConstants.SUCCESS, remoteDir.toString(),
localDir.toString(), getDefaultCLIOptionsOrNull(), conf);
assertNotNull(conf.get(CONF_LABEL_DISTCP_JOB_ID),
"DistCp job id isn't set");
}
/**
* Executes a DistCp using a file system sub-tree with multiple nesting
* levels.
* The filenames are those of the fields initialized in setup.
*
* @param srcFS source FileSystem
* @param srcDir source directory
* @param dstFS destination FileSystem
* @param dstDir destination directory
* @return the target directory of the copy
* @throws Exception if there is a failure
*/
private Path distCpDeepDirectoryStructure(FileSystem srcFS,
Path srcDir,
FileSystem dstFS,
Path dstDir) throws Exception {
initPathFields(srcDir, dstDir);
mkdirs(srcFS, inputSubDir1);
mkdirs(srcFS, inputSubDir2);
byte[] data1 = dataset(100, 33, 43);
createFile(srcFS, inputFile1, true, data1);
byte[] data2 = dataset(200, 43, 53);
createFile(srcFS, inputFile2, true, data2);
byte[] data3 = dataset(300, 53, 63);
createFile(srcFS, inputFile3, true, data3);
createFile(srcFS, inputFile4, true, dataset(400, 53, 63));
createFile(srcFS, inputFile5, true, dataset(500, 53, 63));
Path target = new Path(dstDir, "outputDir");
runDistCp(inputDir, target);
ContractTestUtils.assertIsDirectory(dstFS, target);
lsR("Destination tree after distcp", dstFS, target);
verifyFileContents(dstFS, new Path(target, "inputDir/file1"), data1);
verifyFileContents(dstFS,
new Path(target, "inputDir/subDir1/file2"), data2);
verifyFileContents(dstFS,
new Path(target, "inputDir/subDir2/subDir2/file3"), data3);
return target;
}
/**
* Executes a test using multiple large files.
*
* @param srcFS source FileSystem
* @param srcDir source directory
* @param dstFS destination FileSystem
* @param dstDir destination directory
* @throws Exception if there is a failure
*/
private void largeFiles(FileSystem srcFS, Path srcDir, FileSystem dstFS,
Path dstDir) throws Exception {
int fileSizeKb = conf.getInt(SCALE_TEST_DISTCP_FILE_SIZE_KB,
getDefaultDistCPSizeKb());
if (fileSizeKb < 1) {
skip("File size in " + SCALE_TEST_DISTCP_FILE_SIZE_KB + " is zero");
}
initPathFields(srcDir, dstDir);
Path largeFile1 = new Path(inputDir, "file1");
Path largeFile2 = new Path(inputDir, "file2");
Path largeFile3 = new Path(inputDir, "file3");
int fileSizeMb = fileSizeKb / 1024;
getLogger().info("{} with file size {}", testName.getMethodName(), fileSizeMb);
byte[] data1 = dataset((fileSizeMb + 1) * MB, 33, 43);
createFile(srcFS, largeFile1, true, data1);
byte[] data2 = dataset((fileSizeMb + 2) * MB, 43, 53);
createFile(srcFS, largeFile2, true, data2);
byte[] data3 = dataset((fileSizeMb + 3) * MB, 53, 63);
createFile(srcFS, largeFile3, true, data3);
Path target = new Path(dstDir, "outputDir");
runDistCp(inputDir, target);
verifyFileContents(dstFS, new Path(target, "inputDir/file1"), data1);
verifyFileContents(dstFS, new Path(target, "inputDir/file2"), data2);
verifyFileContents(dstFS, new Path(target, "inputDir/file3"), data3);
}
/**
* Override point. What is the default distcp size
* for large files if not overridden by
* {@link #SCALE_TEST_DISTCP_FILE_SIZE_KB}.
* If 0 then, unless overridden in the configuration,
* the large file tests will not run.
* @return file size.
*/
protected int getDefaultDistCPSizeKb() {
return DEFAULT_DISTCP_SIZE_KB;
}
/**
* Executes DistCp and asserts that the job finished successfully.
* The choice of direct/indirect is based on the value of
* {@link #shouldUseDirectWrite()}.
* @param src source path
* @param dst destination path
* @throws Exception if there is a failure
*/
private void runDistCp(Path src, Path dst) throws Exception {
if (shouldUseDirectWrite()) {
runDistCpDirectWrite(src, dst);
} else {
runDistCpWithRename(src, dst);
}
}
/**
* Run the distcp job.
* @param options distcp options
* @return the job. It will have already completed.
* @throws Exception failure
*/
private Job runDistCp(final DistCpOptions options) throws Exception {
Job job = new DistCp(conf, options).execute();
assertNotNull(job, "Unexpected null job returned from DistCp execution.");
assertTrue(job.isComplete(), "DistCp job did not complete.");
assertTrue(job.isSuccessful(), "DistCp job did not complete successfully.");
return job;
}
/**
* Add any standard options and then build.
* @param builder DistCp option builder
* @return the build options
*/
private DistCpOptions buildWithStandardOptions(
DistCpOptions.Builder builder) {
return builder
.withNumListstatusThreads(DistCpOptions.MAX_NUM_LISTSTATUS_THREADS)
.build();
}
/**
* Creates a directory and any ancestor directories required.
*
* @param fs FileSystem in which to create directories
* @param dir path of directory to create
* @throws Exception if there is a failure
*/
private static void mkdirs(FileSystem fs, Path dir) throws Exception {
assertTrue(fs.mkdirs(dir), "Failed to mkdir " + dir);
}
@Test
public void testDirectWrite() throws Exception {
describe("copy file from local to remote using direct write option");
if (shouldUseDirectWrite()) {
skip("not needed as all other tests use the -direct option.");
}
directWrite(localFS, localDir, remoteFS, remoteDir, true);
}
@Test
public void testNonDirectWrite() throws Exception {
describe("copy file from local to remote without using direct write " +
"option");
directWrite(localFS, localDir, remoteFS, remoteDir, false);
}
@Test
public void testDistCpWithIterator() throws Exception {
describe("Build listing in distCp using the iterator option.");
Path source = new Path(remoteDir, "src");
Path dest = new Path(localDir, "dest");
dest = localFS.makeQualified(dest);
GenericTestUtils
.createFiles(remoteFS, source, getDepth(), getWidth(), getWidth());
GenericTestUtils.LogCapturer log =
GenericTestUtils.LogCapturer.captureLogs(SimpleCopyListing.LOG);
String options = "-useiterator -update -delete" + getDefaultCLIOptions();
DistCpTestUtils.assertRunDistCp(DistCpConstants.SUCCESS, source.toString(),
dest.toString(), options, conf);
// Check the target listing was also done using iterator.
Assertions.assertThat(log.getOutput()).contains(
"Building listing using iterator mode for " + dest.toString());
Assertions.assertThat(RemoteIterators.toList(localFS.listFiles(dest, true)))
.describedAs("files").hasSize(getTotalFiles());
}
public int getDepth() {
return DEFAULT_DEPTH;
}
public int getWidth() {
return DEFAULT_WIDTH;
}
private int getTotalFiles() {
int totalFiles = 0;
for (int i = 1; i <= getDepth(); i++) {
totalFiles += Math.pow(getWidth(), i);
}
return totalFiles;
}
/**
* Override point: should direct write always be used?
* false by default; enable for stores where rename is slow.
* @return true if direct write should be used in all tests.
*/
protected boolean shouldUseDirectWrite() {
return false;
}
/**
* Return the default options for distcp, including,
* if {@link #shouldUseDirectWrite()} is true,
* the -direct option.
* Append or prepend this to string CLIs.
* @return default options.
*/
protected String getDefaultCLIOptions() {
return shouldUseDirectWrite()
? " -direct "
: "";
}
/**
* Return the default options for distcp, including,
* if {@link #shouldUseDirectWrite()} is true,
* the -direct option, null if there are no
* defaults.
* @return default options.
*/
protected String getDefaultCLIOptionsOrNull() {
return shouldUseDirectWrite()
? " -direct "
: null;
}
/**
* Executes a test with support for using direct write option.
*
* @param srcFS source FileSystem
* @param srcDir source directory
* @param dstFS destination FileSystem
* @param dstDir destination directory
* @param directWrite whether to use -directwrite option
* @throws Exception if there is a failure
*/
private void directWrite(FileSystem srcFS, Path srcDir, FileSystem dstFS,
Path dstDir, boolean directWrite) throws Exception {
initPathFields(srcDir, dstDir);
// Create 2 test files
mkdirs(srcFS, inputSubDir1);
byte[] data1 = dataset(64, 33, 43);
createFile(srcFS, inputFile1, true, data1);
byte[] data2 = dataset(200, 43, 53);
createFile(srcFS, inputFile2, true, data2);
Path target = new Path(dstDir, "outputDir");
if (directWrite) {
runDistCpDirectWrite(inputDir, target);
} else {
runDistCpWithRename(inputDir, target);
}
ContractTestUtils.assertIsDirectory(dstFS, target);
lsR("Destination tree after distcp", dstFS, target);
// Verify copied file contents
verifyFileContents(dstFS, new Path(target, "inputDir/file1"), data1);
verifyFileContents(dstFS, new Path(target, "inputDir/subDir1/file2"),
data2);
}
/**
* Run distcp -direct srcDir destDir.
* @param srcDir local source directory
* @param destDir remote destination directory
* @return the completed job
* @throws Exception any failure.
*/
private Job runDistCpDirectWrite(final Path srcDir, final Path destDir)
throws Exception {
describe("\nDistcp -direct from " + srcDir + " to " + destDir);
return runDistCp(buildWithStandardOptions(
new DistCpOptions.Builder(
Collections.singletonList(srcDir), destDir)
.withDirectWrite(true)));
}
/**
* Run distcp srcDir destDir.
* @param srcDir local source directory
* @param destDir remote destination directory
* @return the completed job
* @throws Exception any failure.
*/
private Job runDistCpWithRename(Path srcDir, final Path destDir)
throws Exception {
describe("\nDistcp from " + srcDir + " to " + destDir);
return runDistCp(buildWithStandardOptions(
new DistCpOptions.Builder(
Collections.singletonList(srcDir), destDir)
.withDirectWrite(false)));
}
@Test
public void testDistCpWithFile() throws Exception {
describe("Distcp only file");
Path source = new Path(remoteDir, "file");
Path dest = new Path(localDir, "file");
dest = localFS.makeQualified(dest);
mkdirs(localFS, localDir);
int len = 4;
int base = 0x40;
byte[] block = dataset(len, base, base + len);
ContractTestUtils.createFile(remoteFS, source, true, block);
verifyPathExists(remoteFS, "", source);
verifyPathExists(localFS, "", localDir);
DistCpTestUtils.assertRunDistCp(DistCpConstants.SUCCESS, source.toString(),
dest.toString(), getDefaultCLIOptionsOrNull(), conf);
Assertions
.assertThat(RemoteIterators.toList(localFS.listFiles(dest, true)))
.describedAs("files").hasSize(1);
verifyFileContents(localFS, dest, block);
}
@Test
public void testDistCpWithUpdateExistFile() throws Exception {
describe("Now update an existing file.");
Path source = new Path(remoteDir, "file");
Path dest = new Path(localDir, "file");
dest = localFS.makeQualified(dest);
int len = 4;
int base = 0x40;
byte[] block = dataset(len, base, base + len);
byte[] destBlock = dataset(len, base, base + len + 1);
ContractTestUtils.createFile(remoteFS, source, true, block);
ContractTestUtils.createFile(localFS, dest, true, destBlock);
verifyPathExists(remoteFS, "", source);
verifyPathExists(localFS, "", dest);
DistCpTestUtils.assertRunDistCp(DistCpConstants.SUCCESS, source.toString(),
dest.toString(), "-delete -update" + getDefaultCLIOptions(), conf);
Assertions.assertThat(RemoteIterators.toList(localFS.listFiles(dest, true)))
.hasSize(1);
verifyFileContents(localFS, dest, block);
}
@Test
public void testDistCpUpdateCheckFileSkip() throws Exception {
describe("Distcp update to check file skips.");
Path source = new Path(remoteDir, "file");
Path dest = new Path(localDir, "file");
Path source0byte = new Path(remoteDir, "file_0byte");
Path dest0byte = new Path(localDir, "file_0byte");
dest = localFS.makeQualified(dest);
dest0byte = localFS.makeQualified(dest0byte);
// Creating a source file with certain dataset.
byte[] sourceBlock = dataset(10, 'a', 'z');
// Write the dataset.
ContractTestUtils
.writeDataset(remoteFS, source, sourceBlock, sourceBlock.length,
1024, true);
// Create 0 byte source and target files.
ContractTestUtils.createFile(remoteFS, source0byte, true, new byte[0]);
ContractTestUtils.createFile(localFS, dest0byte, true, new byte[0]);
// Execute the distcp -update job.
Job job = distCpUpdateWithFs(remoteDir, localDir, remoteFS, localFS);
// First distcp -update would normally copy the source to dest.
verifyFileContents(localFS, dest, sourceBlock);
// Verify 1 file was skipped in the distcp -update (The 0 byte file).
// Verify 1 file was copied in the distcp -update (The new source file).
verifySkipAndCopyCounter(job, 1, 1);
// Remove the source file and replace with a file with same name and size
// but different content.
remoteFS.delete(source, false);
Path updatedSource = new Path(remoteDir, "file");
byte[] updatedSourceBlock = dataset(10, 'b', 'z');
ContractTestUtils.writeDataset(remoteFS, updatedSource,
updatedSourceBlock, updatedSourceBlock.length, 1024, true);
// For testing purposes we would take the modification time of the
// updated Source file and add an offset or subtract the offset and set
// that time as the modification time for target file, this way we can
// ensure that our test can emulate a scenario where source is either more
// recently changed after -update so that copy takes place or target file
// is more recently changed which would skip the copying since the source
// has not been recently updated.
FileStatus fsSourceUpd = remoteFS.getFileStatus(updatedSource);
long modTimeSourceUpd = fsSourceUpd.getModificationTime();
// Add by an offset which would ensure enough gap for the test to
// not fail due to race conditions.
long newTargetModTimeNew = modTimeSourceUpd + MODIFICATION_TIME_OFFSET;
localFS.setTimes(dest, newTargetModTimeNew, -1);
// Execute the distcp -update job.
Job updatedSourceJobOldSrc =
distCpUpdateWithFs(remoteDir, localDir, remoteFS,
localFS);
// File contents should remain same since the mod time for target is
// newer than the updatedSource which indicates that the sync happened
// more recently and there is no update.
verifyFileContents(localFS, dest, sourceBlock);
// Skipped both 0 byte file and sourceFile (since mod time of target is
// older than the source it is perceived that source is of older version
// and we can skip it's copy).
verifySkipAndCopyCounter(updatedSourceJobOldSrc, 2, 0);
// Subtract by an offset which would ensure enough gap for the test to
// not fail due to race conditions.
long newTargetModTimeOld =
Math.min(modTimeSourceUpd - MODIFICATION_TIME_OFFSET, 0);
localFS.setTimes(dest, newTargetModTimeOld, -1);
// Execute the distcp -update job.
Job updatedSourceJobNewSrc = distCpUpdateWithFs(remoteDir, localDir,
remoteFS,
localFS);
// Verifying the target directory have both 0 byte file and the content
// file.
Assertions
.assertThat(RemoteIterators.toList(localFS.listFiles(localDir, true)))
.hasSize(2);
// Now the copy should take place and the file contents should change
// since the mod time for target is older than the source file indicating
// that there was an update to the source after the last sync took place.
verifyFileContents(localFS, dest, updatedSourceBlock);
// Verifying we skipped the 0 byte file and copied the updated source
// file (since the modification time of the new source is older than the
// target now).
verifySkipAndCopyCounter(updatedSourceJobNewSrc, 1, 1);
}
/**
* Method to check the skipped and copied counters of a distcp job.
*
* @param job job to check.
* @param skipExpectedValue expected skip counter value.
* @param copyExpectedValue expected copy counter value.
* @throws IOException throw in case of failures.
*/
private void verifySkipAndCopyCounter(Job job,
int skipExpectedValue, int copyExpectedValue) throws IOException {
// get the skip and copy counters from the job.
long skipActualValue = job.getCounters()
.findCounter(CopyMapper.Counter.SKIP).getValue();
long copyActualValue = job.getCounters()
.findCounter(CopyMapper.Counter.COPY).getValue();
// Verify if the actual values equals the expected ones.
assertEquals(copyExpectedValue,
copyActualValue, "Mismatch in COPY counter value");
assertEquals(skipExpectedValue,
skipActualValue, "Mismatch in SKIP counter value");
}
} |
google/guava | 36,242 | android/guava-tests/test/com/google/common/collect/ListsTest.java | /*
* Copyright (C) 2007 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.elementsEqual;
import static com.google.common.collect.Lists.cartesianProduct;
import static com.google.common.collect.Lists.charactersOf;
import static com.google.common.collect.Lists.computeArrayListCapacity;
import static com.google.common.collect.Lists.newArrayListWithExpectedSize;
import static com.google.common.collect.Lists.partition;
import static com.google.common.collect.Lists.transform;
import static com.google.common.collect.ReflectionFreeAssertThrows.assertThrows;
import static com.google.common.collect.testing.IteratorFeature.UNMODIFIABLE;
import static com.google.common.truth.Truth.assertThat;
import static java.lang.System.arraycopy;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.nCopies;
import static java.util.Collections.singletonList;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.collect.testing.IteratorTester;
import com.google.common.collect.testing.ListTestSuiteBuilder;
import com.google.common.collect.testing.TestStringListGenerator;
import com.google.common.collect.testing.features.CollectionFeature;
import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.features.ListFeature;
import com.google.common.collect.testing.google.ListGenerators.CharactersOfCharSequenceGenerator;
import com.google.common.collect.testing.google.ListGenerators.CharactersOfStringGenerator;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.RandomAccess;
import java.util.concurrent.CopyOnWriteArrayList;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jspecify.annotations.NullMarked;
/**
* Unit test for {@code Lists}.
*
* @author Kevin Bourrillion
* @author Mike Bostock
* @author Jared Levy
*/
@GwtCompatible
@NullMarked
public class ListsTest extends TestCase {
private static final Collection<Integer> SOME_COLLECTION = asList(0, 1, 1);
private static final Iterable<Integer> SOME_ITERABLE = new SomeIterable();
private static final class RemoveFirstFunction implements Function<String, String>, Serializable {
@Override
public String apply(String from) {
return (from.length() == 0) ? from : from.substring(1);
}
}
private static class SomeIterable implements Iterable<Integer>, Serializable {
@Override
public Iterator<Integer> iterator() {
return SOME_COLLECTION.iterator();
}
@GwtIncompatible @J2ktIncompatible private static final long serialVersionUID = 0;
}
private static final List<Integer> SOME_LIST = Lists.newArrayList(1, 2, 3, 4);
private static final List<Integer> SOME_SEQUENTIAL_LIST = new LinkedList<>(asList(1, 2, 3, 4));
private static final List<String> SOME_STRING_LIST = asList("1", "2", "3", "4");
private static final Function<Number, String> SOME_FUNCTION = new SomeFunction();
private static class SomeFunction implements Function<Number, String>, Serializable {
@Override
public String apply(Number n) {
return String.valueOf(n);
}
@GwtIncompatible @J2ktIncompatible private static final long serialVersionUID = 0;
}
@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ListsTest.class);
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
String[] rest = new String[elements.length - 1];
arraycopy(elements, 1, rest, 0, elements.length - 1);
return Lists.asList(elements[0], rest);
}
})
.named("Lists.asList, 2 parameter")
.withFeatures(
CollectionSize.SEVERAL,
CollectionSize.ONE,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
String[] rest = new String[elements.length - 2];
arraycopy(elements, 2, rest, 0, elements.length - 2);
return Lists.asList(elements[0], elements[1], rest);
}
})
.named("Lists.asList, 3 parameter")
.withFeatures(
CollectionSize.SEVERAL,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES)
.createTestSuite());
Function<String, String> removeFirst = new RemoveFirstFunction();
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
List<String> fromList = new ArrayList<>();
for (String element : elements) {
fromList.add("q" + checkNotNull(element));
}
return transform(fromList, removeFirst);
}
})
.named("Lists.transform, random access, no nulls")
.withFeatures(
CollectionSize.ANY,
ListFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
List<String> fromList = new LinkedList<>();
for (String element : elements) {
fromList.add("q" + checkNotNull(element));
}
return transform(fromList, removeFirst);
}
})
.named("Lists.transform, sequential access, no nulls")
.withFeatures(
CollectionSize.ANY,
ListFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
List<String> fromList = Lists.newArrayList(elements);
return transform(fromList, Functions.<String>identity());
}
})
.named("Lists.transform, random access, nulls")
.withFeatures(
CollectionSize.ANY,
ListFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
List<String> fromList = new LinkedList<>(asList(elements));
return transform(fromList, Functions.<String>identity());
}
})
.named("Lists.transform, sequential access, nulls")
.withFeatures(
CollectionSize.ANY,
ListFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_VALUES)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
List<String> list = new ArrayList<>();
for (int i = elements.length - 1; i >= 0; i--) {
list.add(elements[i]);
}
return Lists.reverse(list);
}
})
.named("Lists.reverse[ArrayList]")
.withFeatures(
CollectionSize.ANY,
CollectionFeature.ALLOWS_NULL_VALUES,
ListFeature.GENERAL_PURPOSE)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
String[] reverseElements = new String[elements.length];
for (int i = elements.length - 1, j = 0; i >= 0; i--, j++) {
reverseElements[j] = elements[i];
}
return Lists.reverse(asList(reverseElements));
}
})
.named("Lists.reverse[Arrays.asList]")
.withFeatures(
CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, ListFeature.SUPPORTS_SET)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
List<String> list = new LinkedList<>();
for (int i = elements.length - 1; i >= 0; i--) {
list.add(elements[i]);
}
return Lists.reverse(list);
}
})
.named("Lists.reverse[LinkedList]")
.withFeatures(
CollectionSize.ANY,
CollectionFeature.ALLOWS_NULL_VALUES,
ListFeature.GENERAL_PURPOSE)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
ImmutableList.Builder<String> builder = ImmutableList.builder();
for (int i = elements.length - 1; i >= 0; i--) {
builder.add(elements[i]);
}
return Lists.reverse(builder.build());
}
})
.named("Lists.reverse[ImmutableList]")
.withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(new CharactersOfStringGenerator())
.named("Lists.charactersOf[String]")
.withFeatures(
CollectionSize.ANY,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTest(
ListTestSuiteBuilder.using(new CharactersOfCharSequenceGenerator())
.named("Lists.charactersOf[CharSequence]")
.withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
return suite;
}
public void testCharactersOfIsView() {
StringBuilder builder = new StringBuilder("abc");
List<Character> chars = charactersOf(builder);
assertEquals(asList('a', 'b', 'c'), chars);
builder.append("def");
assertEquals(asList('a', 'b', 'c', 'd', 'e', 'f'), chars);
builder.deleteCharAt(5);
assertEquals(asList('a', 'b', 'c', 'd', 'e'), chars);
}
public void testNewArrayListEmpty() {
@SuppressWarnings("UseCollectionConstructor") // test of factory method
ArrayList<Integer> list = Lists.newArrayList();
assertEquals(emptyList(), list);
}
public void testNewArrayListWithCapacity() {
ArrayList<Integer> list = Lists.newArrayListWithCapacity(0);
assertEquals(emptyList(), list);
ArrayList<Integer> bigger = Lists.newArrayListWithCapacity(256);
assertEquals(emptyList(), bigger);
}
public void testNewArrayListWithCapacity_negative() {
assertThrows(IllegalArgumentException.class, () -> Lists.newArrayListWithCapacity(-1));
}
public void testNewArrayListWithExpectedSize() {
ArrayList<Integer> list = newArrayListWithExpectedSize(0);
assertEquals(emptyList(), list);
ArrayList<Integer> bigger = newArrayListWithExpectedSize(256);
assertEquals(emptyList(), bigger);
}
public void testNewArrayListWithExpectedSize_negative() {
assertThrows(IllegalArgumentException.class, () -> newArrayListWithExpectedSize(-1));
}
public void testNewArrayListVarArgs() {
ArrayList<Integer> list = Lists.newArrayList(0, 1, 1);
assertEquals(SOME_COLLECTION, list);
}
public void testComputeArrayListCapacity() {
assertEquals(5, computeArrayListCapacity(0));
assertEquals(13, computeArrayListCapacity(8));
assertEquals(89, computeArrayListCapacity(77));
assertEquals(22000005, computeArrayListCapacity(20000000));
assertEquals(Integer.MAX_VALUE, computeArrayListCapacity(Integer.MAX_VALUE - 1000));
}
public void testNewArrayListFromCollection() {
@SuppressWarnings("UseCollectionConstructor") // test of factory method
ArrayList<Integer> list = Lists.newArrayList(SOME_COLLECTION);
assertEquals(SOME_COLLECTION, list);
}
public void testNewArrayListFromIterable() {
ArrayList<Integer> list = Lists.newArrayList(SOME_ITERABLE);
assertEquals(SOME_COLLECTION, list);
}
public void testNewArrayListFromIterator() {
ArrayList<Integer> list = Lists.newArrayList(SOME_COLLECTION.iterator());
assertEquals(SOME_COLLECTION, list);
}
public void testNewLinkedListEmpty() {
@SuppressWarnings("UseCollectionConstructor") // test of factory method
LinkedList<Integer> list = Lists.newLinkedList();
assertEquals(emptyList(), list);
}
public void testNewLinkedListFromCollection() {
@SuppressWarnings("UseCollectionConstructor") // test of factory method
LinkedList<Integer> list = Lists.newLinkedList(SOME_COLLECTION);
assertEquals(SOME_COLLECTION, list);
}
public void testNewLinkedListFromIterable() {
LinkedList<Integer> list = Lists.newLinkedList(SOME_ITERABLE);
assertEquals(SOME_COLLECTION, list);
}
@J2ktIncompatible
@GwtIncompatible // CopyOnWriteArrayList
public void testNewCOWALEmpty() {
CopyOnWriteArrayList<Integer> list = Lists.newCopyOnWriteArrayList();
assertEquals(emptyList(), list);
}
@J2ktIncompatible
@GwtIncompatible // CopyOnWriteArrayList
public void testNewCOWALFromIterable() {
CopyOnWriteArrayList<Integer> list = Lists.newCopyOnWriteArrayList(SOME_ITERABLE);
assertEquals(SOME_COLLECTION, list);
}
@J2ktIncompatible
@GwtIncompatible // NullPointerTester
public void testNullPointerExceptions() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(Lists.class);
}
/**
* This is just here to illustrate how {@code Arrays#asList} differs from {@code
* Lists#newArrayList}.
*/
public void testArraysAsList() {
List<String> ourWay = Lists.newArrayList("foo", "bar", "baz");
List<String> otherWay = asList("foo", "bar", "baz");
// They're logically equal
assertEquals(ourWay, otherWay);
// The result of Arrays.asList() is mutable
otherWay.set(0, "FOO");
assertEquals("FOO", otherWay.get(0));
// But it can't grow
assertThrows(UnsupportedOperationException.class, () -> otherWay.add("nope"));
// And it can't shrink
assertThrows(UnsupportedOperationException.class, () -> otherWay.remove(2));
}
@J2ktIncompatible
@GwtIncompatible // SerializableTester
public void testAsList1() {
List<String> list = Lists.asList("foo", new String[] {"bar", "baz"});
checkFooBarBazList(list);
SerializableTester.reserializeAndAssert(list);
assertTrue(list instanceof RandomAccess);
new IteratorTester<String>(
5, UNMODIFIABLE, asList("foo", "bar", "baz"), IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<String> newTargetIterator() {
return Lists.asList("foo", new String[] {"bar", "baz"}).iterator();
}
}.test();
}
private void checkFooBarBazList(List<String> list) {
assertThat(list).containsExactly("foo", "bar", "baz").inOrder();
assertEquals(3, list.size());
assertIndexIsOutOfBounds(list, -1);
assertEquals("foo", list.get(0));
assertEquals("bar", list.get(1));
assertEquals("baz", list.get(2));
assertIndexIsOutOfBounds(list, 3);
}
public void testAsList1Small() {
List<String> list = Lists.asList("foo", new String[0]);
assertThat(list).contains("foo");
assertEquals(1, list.size());
assertIndexIsOutOfBounds(list, -1);
assertEquals("foo", list.get(0));
assertIndexIsOutOfBounds(list, 1);
assertTrue(list instanceof RandomAccess);
new IteratorTester<String>(
3, UNMODIFIABLE, singletonList("foo"), IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<String> newTargetIterator() {
return Lists.asList("foo", new String[0]).iterator();
}
}.test();
}
public void testAsList2() {
List<String> list = Lists.asList("foo", "bar", new String[] {"baz"});
checkFooBarBazList(list);
assertTrue(list instanceof RandomAccess);
new IteratorTester<String>(
5, UNMODIFIABLE, asList("foo", "bar", "baz"), IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<String> newTargetIterator() {
return Lists.asList("foo", "bar", new String[] {"baz"}).iterator();
}
}.test();
}
@J2ktIncompatible
@GwtIncompatible // SerializableTester
public void testAsList2Small() {
List<String> list = Lists.asList("foo", "bar", new String[0]);
assertThat(list).containsExactly("foo", "bar").inOrder();
assertEquals(2, list.size());
assertIndexIsOutOfBounds(list, -1);
assertEquals("foo", list.get(0));
assertEquals("bar", list.get(1));
assertIndexIsOutOfBounds(list, 2);
SerializableTester.reserializeAndAssert(list);
assertTrue(list instanceof RandomAccess);
new IteratorTester<String>(
5, UNMODIFIABLE, asList("foo", "bar"), IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<String> newTargetIterator() {
return Lists.asList("foo", "bar", new String[0]).iterator();
}
}.test();
}
private static void assertIndexIsOutOfBounds(List<String> list, int index) {
try {
list.get(index);
fail();
} catch (IndexOutOfBoundsException expected) {
}
}
public void testReverseViewRandomAccess() {
List<Integer> fromList = new ArrayList<>(SOME_LIST);
List<Integer> toList = Lists.reverse(fromList);
assertReverseView(fromList, toList);
}
public void testReverseViewSequential() {
List<Integer> fromList = new LinkedList<>(SOME_SEQUENTIAL_LIST);
List<Integer> toList = Lists.reverse(fromList);
assertReverseView(fromList, toList);
}
private static void assertReverseView(List<Integer> fromList, List<Integer> toList) {
/* fromList modifications reflected in toList */
fromList.set(0, 5);
assertEquals(asList(4, 3, 2, 5), toList);
fromList.add(6);
assertEquals(asList(6, 4, 3, 2, 5), toList);
fromList.add(2, 9);
assertEquals(asList(6, 4, 3, 9, 2, 5), toList);
fromList.remove(Integer.valueOf(2));
assertEquals(asList(6, 4, 3, 9, 5), toList);
fromList.remove(3);
assertEquals(asList(6, 3, 9, 5), toList);
/* toList modifications reflected in fromList */
toList.remove(0);
assertEquals(asList(5, 9, 3), fromList);
toList.add(7);
assertEquals(asList(7, 5, 9, 3), fromList);
toList.add(5);
assertEquals(asList(5, 7, 5, 9, 3), fromList);
toList.remove(Integer.valueOf(5));
assertEquals(asList(5, 7, 9, 3), fromList);
toList.set(1, 8);
assertEquals(asList(5, 7, 8, 3), fromList);
toList.clear();
assertEquals(emptyList(), fromList);
}
@SafeVarargs
private static <E> List<E> list(E... elements) {
return ImmutableList.copyOf(elements);
}
public void testCartesianProduct_binary1x1() {
assertThat(cartesianProduct(list(1), list(2))).contains(list(1, 2));
}
public void testCartesianProduct_binary1x2() {
assertThat(cartesianProduct(list(1), list(2, 3)))
.containsExactly(list(1, 2), list(1, 3))
.inOrder();
}
public void testCartesianProduct_binary2x2() {
assertThat(cartesianProduct(list(1, 2), list(3, 4)))
.containsExactly(list(1, 3), list(1, 4), list(2, 3), list(2, 4))
.inOrder();
}
public void testCartesianProduct_2x2x2() {
assertThat(cartesianProduct(list(0, 1), list(0, 1), list(0, 1)))
.containsExactly(
list(0, 0, 0),
list(0, 0, 1),
list(0, 1, 0),
list(0, 1, 1),
list(1, 0, 0),
list(1, 0, 1),
list(1, 1, 0),
list(1, 1, 1))
.inOrder();
}
public void testCartesianProduct_contains() {
List<List<Integer>> actual = cartesianProduct(list(1, 2), list(3, 4));
assertTrue(actual.contains(list(1, 3)));
assertTrue(actual.contains(list(1, 4)));
assertTrue(actual.contains(list(2, 3)));
assertTrue(actual.contains(list(2, 4)));
assertFalse(actual.contains(list(3, 1)));
}
public void testCartesianProduct_indexOf() {
List<List<Integer>> actual = cartesianProduct(list(1, 2), list(3, 4));
assertEquals(0, actual.indexOf(list(1, 3)));
assertEquals(1, actual.indexOf(list(1, 4)));
assertEquals(2, actual.indexOf(list(2, 3)));
assertEquals(3, actual.indexOf(list(2, 4)));
assertEquals(-1, actual.indexOf(list(3, 1)));
assertEquals(-1, actual.indexOf(list(1)));
assertEquals(-1, actual.indexOf(list(1, 1, 1)));
}
public void testCartesianProduct_lastIndexOf() {
List<List<Integer>> actual = cartesianProduct(list(1, 1), list(2, 3));
assertThat(actual.lastIndexOf(list(1, 2))).isEqualTo(2);
assertThat(actual.lastIndexOf(list(1, 3))).isEqualTo(3);
assertThat(actual.lastIndexOf(list(1, 1))).isEqualTo(-1);
assertThat(actual.lastIndexOf(list(1))).isEqualTo(-1);
assertThat(actual.lastIndexOf(list(1, 1, 1))).isEqualTo(-1);
}
public void testCartesianProduct_unrelatedTypes() {
List<Integer> x = list(1, 2);
List<String> y = list("3", "4");
List<Object> exp1 = list((Object) 1, "3");
List<Object> exp2 = list((Object) 1, "4");
List<Object> exp3 = list((Object) 2, "3");
List<Object> exp4 = list((Object) 2, "4");
assertThat(Lists.<Object>cartesianProduct(x, y))
.containsExactly(exp1, exp2, exp3, exp4)
.inOrder();
}
public void testCartesianProductTooBig() {
List<String> list = nCopies(10000, "foo");
assertThrows(
IllegalArgumentException.class, () -> cartesianProduct(list, list, list, list, list));
}
public void testTransformHashCodeRandomAccess() {
List<String> list = transform(SOME_LIST, SOME_FUNCTION);
assertEquals(SOME_STRING_LIST.hashCode(), list.hashCode());
}
public void testTransformHashCodeSequential() {
List<String> list = transform(SOME_SEQUENTIAL_LIST, SOME_FUNCTION);
assertEquals(SOME_STRING_LIST.hashCode(), list.hashCode());
}
public void testTransformModifiableRandomAccess() {
List<Integer> fromList = new ArrayList<>(SOME_LIST);
List<String> list = transform(fromList, SOME_FUNCTION);
assertTransformModifiable(list);
}
public void testTransformModifiableSequential() {
List<Integer> fromList = new LinkedList<>(SOME_SEQUENTIAL_LIST);
List<String> list = transform(fromList, SOME_FUNCTION);
assertTransformModifiable(list);
}
private static void assertTransformModifiable(List<String> list) {
try {
list.add("5");
fail("transformed list is addable");
} catch (UnsupportedOperationException expected) {
}
list.remove(0);
assertEquals(asList("2", "3", "4"), list);
list.remove("3");
assertEquals(asList("2", "4"), list);
try {
list.set(0, "5");
fail("transformed list is setable");
} catch (UnsupportedOperationException expected) {
}
list.clear();
assertEquals(emptyList(), list);
}
public void testTransformViewRandomAccess() {
List<Integer> fromList = new ArrayList<>(SOME_LIST);
List<String> toList = transform(fromList, SOME_FUNCTION);
assertTransformView(fromList, toList);
}
public void testTransformViewSequential() {
List<Integer> fromList = new LinkedList<>(SOME_SEQUENTIAL_LIST);
List<String> toList = transform(fromList, SOME_FUNCTION);
assertTransformView(fromList, toList);
}
private static void assertTransformView(List<Integer> fromList, List<String> toList) {
/* fromList modifications reflected in toList */
fromList.set(0, 5);
assertEquals(asList("5", "2", "3", "4"), toList);
fromList.add(6);
assertEquals(asList("5", "2", "3", "4", "6"), toList);
fromList.remove(Integer.valueOf(2));
assertEquals(asList("5", "3", "4", "6"), toList);
fromList.remove(2);
assertEquals(asList("5", "3", "6"), toList);
/* toList modifications reflected in fromList */
toList.remove(2);
assertEquals(asList(5, 3), fromList);
toList.remove("5");
assertEquals(asList(3), fromList);
toList.clear();
assertEquals(emptyList(), fromList);
}
public void testTransformRandomAccess() {
List<String> list = transform(SOME_LIST, SOME_FUNCTION);
assertTrue(list instanceof RandomAccess);
}
public void testTransformSequential() {
List<String> list = transform(SOME_SEQUENTIAL_LIST, SOME_FUNCTION);
assertFalse(list instanceof RandomAccess);
}
public void testTransformRandomAccessIsNotEmpty() {
List<String> transformedList = transform(SOME_LIST, SOME_FUNCTION);
assertFalse(transformedList.isEmpty());
}
public void testTransformSequentialIsNotEmpty() {
List<String> transformedList = transform(SOME_SEQUENTIAL_LIST, SOME_FUNCTION);
assertFalse(transformedList.isEmpty());
}
public void testTransformListIteratorRandomAccess() {
List<Integer> fromList = new ArrayList<>(SOME_LIST);
List<String> list = transform(fromList, SOME_FUNCTION);
assertTransformListIterator(list);
}
public void testTransformListIteratorSequential() {
List<Integer> fromList = new LinkedList<>(SOME_SEQUENTIAL_LIST);
List<String> list = transform(fromList, SOME_FUNCTION);
assertTransformListIterator(list);
}
public void testTransformPreservesIOOBEsThrownByFunction() {
assertThrows(
IndexOutOfBoundsException.class,
() ->
transform(
ImmutableList.of("foo", "bar"),
new Function<String, String>() {
@Override
public String apply(String input) {
throw new IndexOutOfBoundsException();
}
})
.toArray());
}
private static void assertTransformListIterator(List<String> list) {
ListIterator<String> iterator = list.listIterator(1);
assertEquals(1, iterator.nextIndex());
assertEquals("2", iterator.next());
assertEquals("3", iterator.next());
assertEquals("4", iterator.next());
assertEquals(4, iterator.nextIndex());
try {
iterator.next();
fail("did not detect end of list");
} catch (NoSuchElementException expected) {
}
assertEquals(3, iterator.previousIndex());
assertEquals("4", iterator.previous());
assertEquals("3", iterator.previous());
assertEquals("2", iterator.previous());
assertTrue(iterator.hasPrevious());
assertEquals("1", iterator.previous());
assertFalse(iterator.hasPrevious());
assertEquals(-1, iterator.previousIndex());
try {
iterator.previous();
fail("did not detect beginning of list");
} catch (NoSuchElementException expected) {
}
iterator.remove();
assertEquals(asList("2", "3", "4"), list);
assertFalse(list.isEmpty());
// An UnsupportedOperationException or IllegalStateException may occur.
try {
iterator.add("1");
fail("transformed list iterator is addable");
} catch (UnsupportedOperationException | IllegalStateException expected) {
}
try {
iterator.set("1");
fail("transformed list iterator is settable");
} catch (UnsupportedOperationException | IllegalStateException expected) {
}
}
public void testTransformIteratorRandomAccess() {
List<Integer> fromList = new ArrayList<>(SOME_LIST);
List<String> list = transform(fromList, SOME_FUNCTION);
assertTransformIterator(list);
}
public void testTransformIteratorSequential() {
List<Integer> fromList = new LinkedList<>(SOME_SEQUENTIAL_LIST);
List<String> list = transform(fromList, SOME_FUNCTION);
assertTransformIterator(list);
}
/**
* This test depends on the fact that {@code AbstractSequentialList.iterator} transforms the
* {@code iterator()} call into a call on {@code listIterator(int)}. This is fine because the
* behavior is clearly documented so it's not expected to change.
*/
public void testTransformedSequentialIterationUsesBackingListIterationOnly() {
List<Integer> randomAccessList = new ArrayList<>(SOME_SEQUENTIAL_LIST);
List<Integer> listIteratorOnlyList = new ListIterationOnlyList<>(randomAccessList);
List<String> transform = transform(listIteratorOnlyList, SOME_FUNCTION);
assertTrue(elementsEqual(transform, transform(randomAccessList, SOME_FUNCTION)));
}
private static class ListIterationOnlyList<E> extends ForwardingList<E> {
private final List<E> realDelegate;
private ListIterationOnlyList(List<E> realDelegate) {
this.realDelegate = realDelegate;
}
@Override
public int size() {
return realDelegate.size();
}
@Override
public ListIterator<E> listIterator(int index) {
return realDelegate.listIterator(index);
}
@Override
protected List<E> delegate() {
throw new UnsupportedOperationException("This list only supports ListIterator");
}
}
private static void assertTransformIterator(List<String> list) {
Iterator<String> iterator = list.iterator();
assertTrue(iterator.hasNext());
assertEquals("1", iterator.next());
assertTrue(iterator.hasNext());
assertEquals("2", iterator.next());
assertTrue(iterator.hasNext());
assertEquals("3", iterator.next());
assertTrue(iterator.hasNext());
assertEquals("4", iterator.next());
assertFalse(iterator.hasNext());
try {
iterator.next();
fail("did not detect end of list");
} catch (NoSuchElementException expected) {
}
iterator.remove();
assertEquals(asList("1", "2", "3"), list);
assertFalse(iterator.hasNext());
}
public void testPartition_badSize() {
List<Integer> source = singletonList(1);
assertThrows(IllegalArgumentException.class, () -> partition(source, 0));
}
public void testPartition_empty() {
List<Integer> source = emptyList();
List<List<Integer>> partitions = partition(source, 1);
assertTrue(partitions.isEmpty());
assertEquals(0, partitions.size());
}
public void testPartition_1_1() {
List<Integer> source = singletonList(1);
List<List<Integer>> partitions = partition(source, 1);
assertEquals(1, partitions.size());
assertEquals(singletonList(1), partitions.get(0));
}
public void testPartition_1_2() {
List<Integer> source = singletonList(1);
List<List<Integer>> partitions = partition(source, 2);
assertEquals(1, partitions.size());
assertEquals(singletonList(1), partitions.get(0));
}
public void testPartition_2_1() {
List<Integer> source = asList(1, 2);
List<List<Integer>> partitions = partition(source, 1);
assertEquals(2, partitions.size());
assertEquals(singletonList(1), partitions.get(0));
assertEquals(singletonList(2), partitions.get(1));
}
public void testPartition_3_2() {
List<Integer> source = asList(1, 2, 3);
List<List<Integer>> partitions = partition(source, 2);
assertEquals(2, partitions.size());
assertEquals(asList(1, 2), partitions.get(0));
assertEquals(asList(3), partitions.get(1));
}
@J2ktIncompatible // Arrays.asList(...).subList() doesn't implement RandomAccess in J2KT.
@GwtIncompatible // ArrayList.subList doesn't implement RandomAccess in GWT.
public void testPartitionRandomAccessTrue() {
List<Integer> source = asList(1, 2, 3);
List<List<Integer>> partitions = partition(source, 2);
assertTrue(
"partition should be RandomAccess, but not: " + partitions.getClass(),
partitions instanceof RandomAccess);
assertTrue(
"partition[0] should be RandomAccess, but not: " + partitions.get(0).getClass(),
partitions.get(0) instanceof RandomAccess);
assertTrue(
"partition[1] should be RandomAccess, but not: " + partitions.get(1).getClass(),
partitions.get(1) instanceof RandomAccess);
}
public void testPartitionRandomAccessFalse() {
List<Integer> source = new LinkedList<>(asList(1, 2, 3));
List<List<Integer>> partitions = partition(source, 2);
assertFalse(partitions instanceof RandomAccess);
assertFalse(partitions.get(0) instanceof RandomAccess);
assertFalse(partitions.get(1) instanceof RandomAccess);
}
// TODO: use the ListTestSuiteBuilder
public void testPartition_view() {
List<Integer> list = asList(1, 2, 3);
List<List<Integer>> partitions = partition(list, 3);
// Changes before the partition is retrieved are reflected
list.set(0, 3);
Iterator<List<Integer>> iterator = partitions.iterator();
// Changes before the partition is retrieved are reflected
list.set(1, 4);
List<Integer> first = iterator.next();
// Changes after are too (unlike Iterables.partition)
list.set(2, 5);
assertEquals(asList(3, 4, 5), first);
// Changes to a sublist also write through to the original list
first.set(1, 6);
assertEquals(asList(3, 6, 5), list);
}
public void testPartitionSize_1() {
List<Integer> list = asList(1, 2, 3);
assertEquals(1, partition(list, Integer.MAX_VALUE).size());
assertEquals(1, partition(list, Integer.MAX_VALUE - 1).size());
}
@GwtIncompatible // cannot do such a big explicit copy
@J2ktIncompatible // too slow
public void testPartitionSize_2() {
assertEquals(2, partition(nCopies(0x40000001, 1), 0x40000000).size());
}
}
|
googleapis/google-cloud-java | 36,306 | java-shopping-merchant-notifications/proto-google-shopping-merchant-notifications-v1beta/src/main/java/com/google/shopping/merchant/notifications/v1beta/CreateNotificationSubscriptionRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/shopping/merchant/notifications/v1beta/notificationsapi.proto
// Protobuf Java Version: 3.25.8
package com.google.shopping.merchant.notifications.v1beta;
/**
*
*
* <pre>
* Request message for the CreateNotificationSubscription method.
* </pre>
*
* Protobuf type {@code
* google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest}
*/
public final class CreateNotificationSubscriptionRequest
extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest)
CreateNotificationSubscriptionRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use CreateNotificationSubscriptionRequest.newBuilder() to construct.
private CreateNotificationSubscriptionRequest(
com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private CreateNotificationSubscriptionRequest() {
parent_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new CreateNotificationSubscriptionRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.shopping.merchant.notifications.v1beta.NotificationsApiProto
.internal_static_google_shopping_merchant_notifications_v1beta_CreateNotificationSubscriptionRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.shopping.merchant.notifications.v1beta.NotificationsApiProto
.internal_static_google_shopping_merchant_notifications_v1beta_CreateNotificationSubscriptionRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
.class,
com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
.Builder.class);
}
private int bitField0_;
public static final int PARENT_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The merchant account that owns the new notification subscription.
* Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The merchant account that owns the new notification subscription.
* Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int NOTIFICATION_SUBSCRIPTION_FIELD_NUMBER = 2;
private com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
notificationSubscription_;
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the notificationSubscription field is set.
*/
@java.lang.Override
public boolean hasNotificationSubscription() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The notificationSubscription.
*/
@java.lang.Override
public com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
getNotificationSubscription() {
return notificationSubscription_ == null
? com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
.getDefaultInstance()
: notificationSubscription_;
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.shopping.merchant.notifications.v1beta.NotificationSubscriptionOrBuilder
getNotificationSubscriptionOrBuilder() {
return notificationSubscription_ == null
? com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
.getDefaultInstance()
: notificationSubscription_;
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_);
}
if (((bitField0_ & 0x00000001) != 0)) {
output.writeMessage(2, getNotificationSubscription());
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
2, getNotificationSubscription());
}
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.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest)) {
return super.equals(obj);
}
com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest other =
(com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest)
obj;
if (!getParent().equals(other.getParent())) return false;
if (hasNotificationSubscription() != other.hasNotificationSubscription()) return false;
if (hasNotificationSubscription()) {
if (!getNotificationSubscription().equals(other.getNotificationSubscription())) 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();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
if (hasNotificationSubscription()) {
hash = (37 * hash) + NOTIFICATION_SUBSCRIPTION_FIELD_NUMBER;
hash = (53 * hash) + getNotificationSubscription().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseFrom(
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseFrom(com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
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.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
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.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
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.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
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.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
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;
}
/**
*
*
* <pre>
* Request message for the CreateNotificationSubscription method.
* </pre>
*
* Protobuf type {@code
* google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest)
com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.shopping.merchant.notifications.v1beta.NotificationsApiProto
.internal_static_google_shopping_merchant_notifications_v1beta_CreateNotificationSubscriptionRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.shopping.merchant.notifications.v1beta.NotificationsApiProto
.internal_static_google_shopping_merchant_notifications_v1beta_CreateNotificationSubscriptionRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest.class,
com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest.Builder.class);
}
// Construct using
// com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getNotificationSubscriptionFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
parent_ = "";
notificationSubscription_ = null;
if (notificationSubscriptionBuilder_ != null) {
notificationSubscriptionBuilder_.dispose();
notificationSubscriptionBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.shopping.merchant.notifications.v1beta.NotificationsApiProto
.internal_static_google_shopping_merchant_notifications_v1beta_CreateNotificationSubscriptionRequest_descriptor;
}
@java.lang.Override
public com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
getDefaultInstanceForType() {
return com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
.getDefaultInstance();
}
@java.lang.Override
public com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
build() {
com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
buildPartial() {
com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
result =
new com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.parent_ = parent_;
}
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.notificationSubscription_ =
notificationSubscriptionBuilder_ == null
? notificationSubscription_
: notificationSubscriptionBuilder_.build();
to_bitField0_ |= 0x00000001;
}
result.bitField0_ |= to_bitField0_;
}
@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.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest) {
return mergeFrom(
(com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest)
other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
other) {
if (other
== com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
.getDefaultInstance()) return this;
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000001;
onChanged();
}
if (other.hasNotificationSubscription()) {
mergeNotificationSubscription(other.getNotificationSubscription());
}
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 10:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(
getNotificationSubscriptionFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The merchant account that owns the new notification subscription.
* Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The merchant account that owns the new notification subscription.
* Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The merchant account that owns the new notification subscription.
* Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The merchant account that owns the new notification subscription.
* Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The merchant account that owns the new notification subscription.
* Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
notificationSubscription_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription,
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription.Builder,
com.google.shopping.merchant.notifications.v1beta.NotificationSubscriptionOrBuilder>
notificationSubscriptionBuilder_;
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the notificationSubscription field is set.
*/
public boolean hasNotificationSubscription() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The notificationSubscription.
*/
public com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
getNotificationSubscription() {
if (notificationSubscriptionBuilder_ == null) {
return notificationSubscription_ == null
? com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
.getDefaultInstance()
: notificationSubscription_;
} else {
return notificationSubscriptionBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setNotificationSubscription(
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription value) {
if (notificationSubscriptionBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
notificationSubscription_ = value;
} else {
notificationSubscriptionBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setNotificationSubscription(
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription.Builder
builderForValue) {
if (notificationSubscriptionBuilder_ == null) {
notificationSubscription_ = builderForValue.build();
} else {
notificationSubscriptionBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeNotificationSubscription(
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription value) {
if (notificationSubscriptionBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& notificationSubscription_ != null
&& notificationSubscription_
!= com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
.getDefaultInstance()) {
getNotificationSubscriptionBuilder().mergeFrom(value);
} else {
notificationSubscription_ = value;
}
} else {
notificationSubscriptionBuilder_.mergeFrom(value);
}
if (notificationSubscription_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearNotificationSubscription() {
bitField0_ = (bitField0_ & ~0x00000002);
notificationSubscription_ = null;
if (notificationSubscriptionBuilder_ != null) {
notificationSubscriptionBuilder_.dispose();
notificationSubscriptionBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.shopping.merchant.notifications.v1beta.NotificationSubscription.Builder
getNotificationSubscriptionBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getNotificationSubscriptionFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.shopping.merchant.notifications.v1beta.NotificationSubscriptionOrBuilder
getNotificationSubscriptionOrBuilder() {
if (notificationSubscriptionBuilder_ != null) {
return notificationSubscriptionBuilder_.getMessageOrBuilder();
} else {
return notificationSubscription_ == null
? com.google.shopping.merchant.notifications.v1beta.NotificationSubscription
.getDefaultInstance()
: notificationSubscription_;
}
}
/**
*
*
* <pre>
* Required. The notification subscription to create.
* </pre>
*
* <code>
* .google.shopping.merchant.notifications.v1beta.NotificationSubscription notification_subscription = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription,
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription.Builder,
com.google.shopping.merchant.notifications.v1beta.NotificationSubscriptionOrBuilder>
getNotificationSubscriptionFieldBuilder() {
if (notificationSubscriptionBuilder_ == null) {
notificationSubscriptionBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription,
com.google.shopping.merchant.notifications.v1beta.NotificationSubscription.Builder,
com.google.shopping.merchant.notifications.v1beta
.NotificationSubscriptionOrBuilder>(
getNotificationSubscription(), getParentForChildren(), isClean());
notificationSubscription_ = null;
}
return notificationSubscriptionBuilder_;
}
@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.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest)
}
// @@protoc_insertion_point(class_scope:google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest)
private static final com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE =
new com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest();
}
public static com.google.shopping.merchant.notifications.v1beta
.CreateNotificationSubscriptionRequest
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<CreateNotificationSubscriptionRequest> PARSER =
new com.google.protobuf.AbstractParser<CreateNotificationSubscriptionRequest>() {
@java.lang.Override
public CreateNotificationSubscriptionRequest 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<CreateNotificationSubscriptionRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<CreateNotificationSubscriptionRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.shopping.merchant.notifications.v1beta.CreateNotificationSubscriptionRequest
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,355 | java-visionai/proto-google-cloud-visionai-v1/src/main/java/com/google/cloud/visionai/v1/UpdateSearchHypernymRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/visionai/v1/warehouse.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.visionai.v1;
/**
*
*
* <pre>
* Request message for updating SearchHypernym.
* </pre>
*
* Protobuf type {@code google.cloud.visionai.v1.UpdateSearchHypernymRequest}
*/
public final class UpdateSearchHypernymRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.visionai.v1.UpdateSearchHypernymRequest)
UpdateSearchHypernymRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateSearchHypernymRequest.newBuilder() to construct.
private UpdateSearchHypernymRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateSearchHypernymRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateSearchHypernymRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateSearchHypernymRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateSearchHypernymRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.visionai.v1.UpdateSearchHypernymRequest.class,
com.google.cloud.visionai.v1.UpdateSearchHypernymRequest.Builder.class);
}
private int bitField0_;
public static final int SEARCH_HYPERNYM_FIELD_NUMBER = 1;
private com.google.cloud.visionai.v1.SearchHypernym searchHypernym_;
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the searchHypernym field is set.
*/
@java.lang.Override
public boolean hasSearchHypernym() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The searchHypernym.
*/
@java.lang.Override
public com.google.cloud.visionai.v1.SearchHypernym getSearchHypernym() {
return searchHypernym_ == null
? com.google.cloud.visionai.v1.SearchHypernym.getDefaultInstance()
: searchHypernym_;
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.visionai.v1.SearchHypernymOrBuilder getSearchHypernymOrBuilder() {
return searchHypernym_ == null
? com.google.cloud.visionai.v1.SearchHypernym.getDefaultInstance()
: searchHypernym_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getSearchHypernym());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getSearchHypernym());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.visionai.v1.UpdateSearchHypernymRequest)) {
return super.equals(obj);
}
com.google.cloud.visionai.v1.UpdateSearchHypernymRequest other =
(com.google.cloud.visionai.v1.UpdateSearchHypernymRequest) obj;
if (hasSearchHypernym() != other.hasSearchHypernym()) return false;
if (hasSearchHypernym()) {
if (!getSearchHypernym().equals(other.getSearchHypernym())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasSearchHypernym()) {
hash = (37 * hash) + SEARCH_HYPERNYM_FIELD_NUMBER;
hash = (53 * hash) + getSearchHypernym().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest 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.visionai.v1.UpdateSearchHypernymRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest 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.visionai.v1.UpdateSearchHypernymRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest 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.visionai.v1.UpdateSearchHypernymRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest 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.visionai.v1.UpdateSearchHypernymRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest 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.visionai.v1.UpdateSearchHypernymRequest 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;
}
/**
*
*
* <pre>
* Request message for updating SearchHypernym.
* </pre>
*
* Protobuf type {@code google.cloud.visionai.v1.UpdateSearchHypernymRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.visionai.v1.UpdateSearchHypernymRequest)
com.google.cloud.visionai.v1.UpdateSearchHypernymRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateSearchHypernymRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateSearchHypernymRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.visionai.v1.UpdateSearchHypernymRequest.class,
com.google.cloud.visionai.v1.UpdateSearchHypernymRequest.Builder.class);
}
// Construct using com.google.cloud.visionai.v1.UpdateSearchHypernymRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getSearchHypernymFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
searchHypernym_ = null;
if (searchHypernymBuilder_ != null) {
searchHypernymBuilder_.dispose();
searchHypernymBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.visionai.v1.WarehouseProto
.internal_static_google_cloud_visionai_v1_UpdateSearchHypernymRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateSearchHypernymRequest getDefaultInstanceForType() {
return com.google.cloud.visionai.v1.UpdateSearchHypernymRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateSearchHypernymRequest build() {
com.google.cloud.visionai.v1.UpdateSearchHypernymRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateSearchHypernymRequest buildPartial() {
com.google.cloud.visionai.v1.UpdateSearchHypernymRequest result =
new com.google.cloud.visionai.v1.UpdateSearchHypernymRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.visionai.v1.UpdateSearchHypernymRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.searchHypernym_ =
searchHypernymBuilder_ == null ? searchHypernym_ : searchHypernymBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.visionai.v1.UpdateSearchHypernymRequest) {
return mergeFrom((com.google.cloud.visionai.v1.UpdateSearchHypernymRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.visionai.v1.UpdateSearchHypernymRequest other) {
if (other == com.google.cloud.visionai.v1.UpdateSearchHypernymRequest.getDefaultInstance())
return this;
if (other.hasSearchHypernym()) {
mergeSearchHypernym(other.getSearchHypernym());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(getSearchHypernymFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.cloud.visionai.v1.SearchHypernym searchHypernym_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.visionai.v1.SearchHypernym,
com.google.cloud.visionai.v1.SearchHypernym.Builder,
com.google.cloud.visionai.v1.SearchHypernymOrBuilder>
searchHypernymBuilder_;
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the searchHypernym field is set.
*/
public boolean hasSearchHypernym() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The searchHypernym.
*/
public com.google.cloud.visionai.v1.SearchHypernym getSearchHypernym() {
if (searchHypernymBuilder_ == null) {
return searchHypernym_ == null
? com.google.cloud.visionai.v1.SearchHypernym.getDefaultInstance()
: searchHypernym_;
} else {
return searchHypernymBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setSearchHypernym(com.google.cloud.visionai.v1.SearchHypernym value) {
if (searchHypernymBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
searchHypernym_ = value;
} else {
searchHypernymBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setSearchHypernym(
com.google.cloud.visionai.v1.SearchHypernym.Builder builderForValue) {
if (searchHypernymBuilder_ == null) {
searchHypernym_ = builderForValue.build();
} else {
searchHypernymBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeSearchHypernym(com.google.cloud.visionai.v1.SearchHypernym value) {
if (searchHypernymBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& searchHypernym_ != null
&& searchHypernym_
!= com.google.cloud.visionai.v1.SearchHypernym.getDefaultInstance()) {
getSearchHypernymBuilder().mergeFrom(value);
} else {
searchHypernym_ = value;
}
} else {
searchHypernymBuilder_.mergeFrom(value);
}
if (searchHypernym_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearSearchHypernym() {
bitField0_ = (bitField0_ & ~0x00000001);
searchHypernym_ = null;
if (searchHypernymBuilder_ != null) {
searchHypernymBuilder_.dispose();
searchHypernymBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.visionai.v1.SearchHypernym.Builder getSearchHypernymBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getSearchHypernymFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.visionai.v1.SearchHypernymOrBuilder getSearchHypernymOrBuilder() {
if (searchHypernymBuilder_ != null) {
return searchHypernymBuilder_.getMessageOrBuilder();
} else {
return searchHypernym_ == null
? com.google.cloud.visionai.v1.SearchHypernym.getDefaultInstance()
: searchHypernym_;
}
}
/**
*
*
* <pre>
* Required. The SearchHypernym to update.
* The search hypernym's `name` field is used to identify the search hypernym
* to be updated. Format:
* `projects/{project_number}/locations/{location}/corpora/{corpus}/searchHypernyms/{search_hypernym}`
* </pre>
*
* <code>
* .google.cloud.visionai.v1.SearchHypernym search_hypernym = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.visionai.v1.SearchHypernym,
com.google.cloud.visionai.v1.SearchHypernym.Builder,
com.google.cloud.visionai.v1.SearchHypernymOrBuilder>
getSearchHypernymFieldBuilder() {
if (searchHypernymBuilder_ == null) {
searchHypernymBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.visionai.v1.SearchHypernym,
com.google.cloud.visionai.v1.SearchHypernym.Builder,
com.google.cloud.visionai.v1.SearchHypernymOrBuilder>(
getSearchHypernym(), getParentForChildren(), isClean());
searchHypernym_ = null;
}
return searchHypernymBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* The list of fields to be updated. If left unset, all field paths will be
* updated/overwritten.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.visionai.v1.UpdateSearchHypernymRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.visionai.v1.UpdateSearchHypernymRequest)
private static final com.google.cloud.visionai.v1.UpdateSearchHypernymRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.visionai.v1.UpdateSearchHypernymRequest();
}
public static com.google.cloud.visionai.v1.UpdateSearchHypernymRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateSearchHypernymRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateSearchHypernymRequest>() {
@java.lang.Override
public UpdateSearchHypernymRequest 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<UpdateSearchHypernymRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateSearchHypernymRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.visionai.v1.UpdateSearchHypernymRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/phoenix | 36,617 | phoenix-core/src/it/java/org/apache/phoenix/jdbc/FailoverPhoenixConnectionIT.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.phoenix.jdbc;
import static org.apache.hadoop.test.GenericTestUtils.waitFor;
import static org.apache.phoenix.exception.SQLExceptionCode.CANNOT_ESTABLISH_CONNECTION;
import static org.apache.phoenix.jdbc.HighAvailabilityGroup.PHOENIX_HA_GROUP_ATTR;
import static org.apache.phoenix.jdbc.HighAvailabilityGroup.URLS;
import static org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.HBaseTestingUtilityPair;
import static org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.doTestBasicOperationsWithConnection;
import static org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.doTestBasicOperationsWithStatement;
import static org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.getHighAvailibilityGroup;
import static org.apache.phoenix.query.BaseTest.extractThreadPoolExecutorFromCQSI;
import static org.apache.phoenix.query.QueryServices.CQSI_THREAD_POOL_ALLOW_CORE_THREAD_TIMEOUT;
import static org.apache.phoenix.query.QueryServices.CQSI_THREAD_POOL_CORE_POOL_SIZE;
import static org.apache.phoenix.query.QueryServices.CQSI_THREAD_POOL_ENABLED;
import static org.apache.phoenix.query.QueryServices.CQSI_THREAD_POOL_KEEP_ALIVE_SECONDS;
import static org.apache.phoenix.query.QueryServices.CQSI_THREAD_POOL_MAX_QUEUE;
import static org.apache.phoenix.query.QueryServices.CQSI_THREAD_POOL_MAX_THREADS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
import org.apache.phoenix.exception.FailoverSQLException;
import org.apache.phoenix.jdbc.ClusterRoleRecord.ClusterRole;
import org.apache.phoenix.monitoring.MetricType;
import org.apache.phoenix.query.ConnectionQueryServices;
import org.apache.phoenix.query.ConnectionQueryServicesImpl;
import org.apache.phoenix.util.PhoenixRuntime;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test failover basics for {@link FailoverPhoenixConnection}.
*/
@Category(NeedsOwnMiniClusterTest.class)
public class FailoverPhoenixConnectionIT {
private static final Logger LOG = LoggerFactory.getLogger(FailoverPhoenixConnectionIT.class);
private static final HBaseTestingUtilityPair CLUSTERS = new HBaseTestingUtilityPair();
@Rule
public final TestName testName = new TestName();
/** Client properties to create a connection per test. */
private Properties clientProperties;
/** HA group for this test. */
private HighAvailabilityGroup haGroup;
/** Table name per test case. */
private String tableName;
/** HA Group name for this test. */
private String haGroupName;
private final ClusterRoleRecord.RegistryType registryType = ClusterRoleRecord.RegistryType.ZK;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
CLUSTERS.start();
DriverManager.registerDriver(PhoenixDriver.INSTANCE);
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
DriverManager.deregisterDriver(PhoenixDriver.INSTANCE);
CLUSTERS.close();
}
@Before
public void setup() throws Exception {
haGroupName = testName.getMethodName();
clientProperties = HighAvailabilityTestingUtility.getHATestProperties();
clientProperties.setProperty(PHOENIX_HA_GROUP_ATTR, haGroupName);
clientProperties.setProperty(CQSI_THREAD_POOL_ENABLED, String.valueOf(true));
clientProperties.setProperty(CQSI_THREAD_POOL_KEEP_ALIVE_SECONDS, String.valueOf(13));
clientProperties.setProperty(CQSI_THREAD_POOL_CORE_POOL_SIZE, String.valueOf(17));
clientProperties.setProperty(CQSI_THREAD_POOL_MAX_THREADS, String.valueOf(19));
clientProperties.setProperty(CQSI_THREAD_POOL_MAX_QUEUE, String.valueOf(23));
clientProperties.setProperty(CQSI_THREAD_POOL_ALLOW_CORE_THREAD_TIMEOUT, String.valueOf(true));
// Make first cluster ACTIVE
CLUSTERS.initClusterRole(haGroupName, HighAvailabilityPolicy.FAILOVER);
haGroup = getHighAvailibilityGroup(CLUSTERS.getJdbcHAUrl(), clientProperties);
LOG.info("Initialized haGroup {} with URL {}", haGroup, CLUSTERS.getJdbcHAUrl());
tableName = testName.getMethodName().toUpperCase();
CLUSTERS.createTableOnClusterPair(haGroup, tableName);
}
@After
public void tearDown() throws Exception {
try {
haGroup.close();
PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup), haGroup.getProperties()).close();
PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrl2(haGroup), haGroup.getProperties()).close();
} catch (Exception e) {
LOG.error("Fail to tear down the HA group and the CQS. Will ignore", e);
}
}
@Test
public void testCQSIThreadPoolCreation() throws Exception {
try (Connection conn = createFailoverConnection()) {
FailoverPhoenixConnection failoverConn = conn.unwrap(FailoverPhoenixConnection.class);
// verify connection#1
ConnectionQueryServices cqsi = PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup), clientProperties);
ConnectionQueryServices cqsiFromConn = failoverConn.getWrappedConnection().getQueryServices();
// Check that same ThreadPoolExecutor object is used for CQSIs
Assert.assertSame(extractThreadPoolExecutorFromCQSI(cqsi),
extractThreadPoolExecutorFromCQSI(cqsiFromConn));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
/**
* Test Phoenix connection creation and basic operations with HBase cluster pair.
*/
@Test(timeout = 300000)
public void testOperationUsingConnection() throws Exception {
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
}
}
/**
* Test close() once more should not fail, as the second close should be a no-op.
*/
@Test(timeout = 300000)
public void testCloseConnectionOnceMore() throws Exception {
Connection conn = createFailoverConnection();
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
conn.close();
conn.close(); // this is NOT duplicate code, but instead this is essential for this test.
}
/**
* Tests that new Phoenix connections are not created during failover.
*/
@Test(timeout = 300000)
public void testConnectionCreationFailsIfNoActiveCluster() throws Exception {
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
}
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.STANDBY);
try {
createFailoverConnection();
fail("Should have failed because neither cluster is ACTIVE");
} catch (SQLException e) {
LOG.info("Got expected exception when creating new connection", e);
assertEquals(CANNOT_ESTABLISH_CONNECTION.getErrorCode(), e.getErrorCode());
} // all other type of exception will fail this test.
}
/**
* Tests new Phoenix connections are created if one cluster is OFFLINE and the other ACTIVE.
*/
@Test(timeout = 300000)
public void testConnectionOneOfflineOneActive() throws Exception {
CLUSTERS.transitClusterRole(haGroup, ClusterRole.OFFLINE, ClusterRole.ACTIVE);
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
}
}
/**
* Tests that new Phoenix connections are not created if both clusters are OFFLINE.
*/
@Test(timeout = 300000)
public void testConnectionCreationFailsIfBothClustersOffline() throws Exception {
CLUSTERS.transitClusterRole(haGroup, ClusterRole.OFFLINE, ClusterRole.OFFLINE);
try {
createFailoverConnection();
fail("Should have failed because both clusters are OFFLINE");
} catch (SQLException e) {
LOG.info("Got expected exception when creating new connection", e);
assertEquals(CANNOT_ESTABLISH_CONNECTION.getErrorCode(), e.getErrorCode());
} // all other type of exception will fail this test.
}
/**
* Tests that existing wrapped Phoenix connection is closed in the Failover event.
*/
@Test(timeout = 300000)
public void testWrappedConnectionClosedAfterStandby() throws Exception {
Connection conn = createFailoverConnection();
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
// The wrapped connection is still against the first cluster, and is closed
PhoenixConnection pc = ((FailoverPhoenixConnection) conn).getWrappedConnection();
assertNotNull(pc);
assertEquals(CLUSTERS.getJdbcUrl1(haGroup), pc.getURL());
assertTrue(pc.isClosed());
doTestActionShouldFailBecauseOfFailover(conn::createStatement);
}
/**
* Tests that existing Phoenix statement is closed when cluster transits into STANDBY.
*/
@Test(timeout = 300000)
public void testStatementClosedAfterStandby() throws Exception {
Connection conn = createFailoverConnection();
Statement stmt = conn.createStatement();
doTestBasicOperationsWithStatement(conn, stmt, tableName);
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
assertFalse(conn.isClosed());
assertTrue(stmt.isClosed());
doTestActionShouldFailBecauseOfFailover(() -> stmt.executeQuery("SELECT * FROM " + tableName));
}
/**
* Tests non-HA connection (vanilla Phoenix connection) is intact when cluster role transits. The
* reason is that, high availability group has its own CQSI which tracks only those Phoenix
* connections that are wrapped by failover connections.
*/
@Test(timeout = 300000)
public void testNonHAConnectionNotClosedAfterFailover() throws Exception {
String firstUrl = String.format("jdbc:phoenix+zk:%s", CLUSTERS.getZkUrl1());
// This is a vanilla Phoenix connection without using high availability (HA) feature.
Connection phoenixConn = DriverManager.getConnection(firstUrl, new Properties());
Connection failoverConn = createFailoverConnection();
PhoenixConnection wrappedConn =
((FailoverPhoenixConnection) failoverConn).getWrappedConnection();
assertFalse(phoenixConn.isClosed());
assertFalse(failoverConn.isClosed());
assertFalse(wrappedConn.isClosed());
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
assertFalse(phoenixConn.isClosed()); // normal Phoenix connection is not closed
assertFalse(failoverConn.isClosed()); // failover connection is not closed by close() method
assertTrue(wrappedConn.isClosed());
}
/**
* Tests that one HA group cluster role transit will not affect connections in other HA groups.
*/
@Test(timeout = 300000)
public void testOtherHAGroupConnectionUnchanged() throws Exception {
Connection conn = createFailoverConnection();
PhoenixConnection wrappedConn = ((FailoverPhoenixConnection) conn).getWrappedConnection();
// Following we create a new HA group and create a connection against this HA group
String haGroupName2 = haGroup.getGroupInfo().getName() + "2";
initClusterRoleRecord(haGroupName2);
Properties clientProperties2 = new Properties(clientProperties);
clientProperties2.setProperty(PHOENIX_HA_GROUP_ATTR, haGroupName2);
Connection conn2 = DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(), clientProperties2);
PhoenixConnection wrappedConn2 = ((FailoverPhoenixConnection) conn2).getWrappedConnection();
assertFalse(wrappedConn.isClosed());
assertFalse(wrappedConn2.isClosed());
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
assertTrue(wrappedConn.isClosed());
assertFalse(wrappedConn2.isClosed());
}
/**
* Test that failover can finish even if one connection can not be closed. When once cluster
* becomes STANDBY from ACTIVE, all its connections and the associated CQS will get closed
* asynchronously. In case of errors when closing those connections and CQS, the HA group is still
* able to transit to target state after the maximum timeout. Closing the existing connections is
* guaranteed with best effort and timeout in favor of improved availability.
* @see #testFailoverTwice which fails over back to the first cluster
*/
@Test(timeout = 300000)
public void testFailoverCanFinishWhenOneConnectionGotStuckClosing() throws Exception {
Connection conn = createFailoverConnection();
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
assertEquals(CLUSTERS.getJdbcUrl1(haGroup), // active connection is against the first cluster
conn.unwrap(FailoverPhoenixConnection.class).getWrappedConnection().getURL());
// Spy the wrapped connection
Connection wrapped = conn.unwrap(FailoverPhoenixConnection.class).getWrappedConnection();
Connection spy = Mockito.spy(wrapped);
final CountDownLatch latch = new CountDownLatch(1);
// Make close() stuck before closing
doAnswer((invocation) -> {
latch.await();
invocation.callRealMethod();
return null;
}).when(spy).close();
ConnectionQueryServices cqs = PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup), clientProperties);
// replace the wrapped connection with the spied connection in CQS
cqs.removeConnection(wrapped.unwrap(PhoenixConnection.class));
cqs.addConnection(spy.unwrap(PhoenixConnection.class));
// (ACTIVE, STANDBY) -> (STANDBY, ACTIVE)
// The transition will finish as we set PHOENIX_HA_TRANSITION_TIMEOUT_MS_KEY for this class
// even though the spied connection is stuck at the latch when closing
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
// Verify the spied object has been called once
verify(spy, times(1)).close();
// The spy is not closed because the real method was blocked by latch
assertFalse(spy.isClosed());
// connection is not closed as Phoenix HA does not close failover connections.
assertFalse(conn.isClosed());
try (Connection conn2 = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn2, tableName, haGroupName);
assertEquals(CLUSTERS.getJdbcUrl2(haGroup), // active connection is against the second cluster
conn2.unwrap(FailoverPhoenixConnection.class).getWrappedConnection().getURL());
}
latch.countDown();
conn.close();
// The CQS should be closed eventually.
waitFor(() -> {
try {
((ConnectionQueryServicesImpl) cqs).checkClosed();
return false;
} catch (IllegalStateException e) {
LOG.info("CQS got closed as we get expected exception.", e);
return true;
}
}, 100, 10_000);
}
/**
* This is to make sure all Phoenix connections are closed when cluster becomes STANDBY. Test with
* many connections.
*/
@Test(timeout = 300000)
public void testAllWrappedConnectionsClosedAfterStandby() throws Exception {
short numberOfConnections = 10;
List<Connection> connectionList = new ArrayList<>(numberOfConnections);
for (short i = 0; i < numberOfConnections; i++) {
connectionList.add(createFailoverConnection());
}
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
for (short i = 0; i < numberOfConnections; i++) {
LOG.info("Asserting connection number {}", i);
FailoverPhoenixConnection conn = ((FailoverPhoenixConnection) connectionList.get(i));
assertFalse(conn.isClosed());
assertTrue(conn.getWrappedConnection().isClosed());
}
}
/**
* This is to make sure all Phoenix connections are closed when cluster becomes STANDBY. Test with
* many connections.
*/
@Test(timeout = 300000)
public void testAllWrappedConnectionsClosedAfterStandbyAsync() throws Exception {
short numberOfThreads = 10;
// Test thread waits for half of connections to be created before triggering a failover
CountDownLatch latchToTransitRole = new CountDownLatch(numberOfThreads / 2);
// Clients wait for failover to finish before creating more connections
CountDownLatch latchToCreateMoreConnections = new CountDownLatch(1);
ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
List<Future<Connection>> connections = new ArrayList<>(numberOfThreads);
for (short i = 0; i < numberOfThreads; i++) {
Future<Connection> future = executor.submit(() -> {
if (latchToTransitRole.getCount() <= 0) {
latchToCreateMoreConnections.await();
}
Connection conn = createFailoverConnection();
latchToTransitRole.countDown();
return conn;
});
connections.add(future);
}
latchToTransitRole.await();
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.STANDBY);
latchToCreateMoreConnections.countDown();
waitFor(() -> {
for (Future<Connection> future : connections) {
if (!future.isDone()) {
return false;
}
try {
Connection conn = future.get(100, TimeUnit.MILLISECONDS);
FailoverPhoenixConnection failoverConn = (FailoverPhoenixConnection) conn;
if (!failoverConn.getWrappedConnection().isClosed()) {
return false;
}
} catch (Exception e) {
LOG.info("Got exception when getting client connection; ignored", e);
}
}
return true;
}, 100, 60_000);
}
/**
* Test that new Phoenix connection can be created after cluster role finishes transition.
* Application may enable HA failover feature but it does not call failover() explicitly. In that
* case, retrying the business logic will request a new JDBC connection. This connection will
* connect to the new ACTIVE cluster, if any.
*/
@Test(timeout = 300000)
public void testNewPhoenixConnectionAfterFailover() throws Exception {
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
}
// Make the second cluster the active one.
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
}
}
/**
* Test that we can failover to one cluster and then failover back.
* @see #testConnectionCreationFailsIfNoActiveCluster
* @see #testFailoverCanFinishWhenOneConnectionGotStuckClosing
*/
@Test(timeout = 300000)
public void testFailoverTwice() throws Exception {
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
assertEquals(CLUSTERS.getJdbcUrl1(haGroup), // active connection is against the first cluster
conn.unwrap(FailoverPhoenixConnection.class).getWrappedConnection().getURL());
}
// Make the second cluster the active one.
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
assertEquals(CLUSTERS.getJdbcUrl2(haGroup), // active connection is against the second cluster
conn.unwrap(FailoverPhoenixConnection.class).getWrappedConnection().getURL());
}
// Failover back to the first cluster.
CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE, ClusterRole.STANDBY);
try (Connection conn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
assertEquals(CLUSTERS.getJdbcUrl1(haGroup), // active connection is against the first cluster
conn.unwrap(FailoverPhoenixConnection.class).getWrappedConnection().getURL());
}
}
/**
* Test that we can failover Phoenix connection explicitly.
*/
@Test(timeout = 300000)
public void testFailoverConnectionExplicitly() throws Exception {
Connection conn = createFailoverConnection();
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
// Make the second cluster ACTIVE will not change the wrapped connection.
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
doTestActionShouldFailBecauseOfFailover(conn::createStatement);
// failover explicitly
FailoverPhoenixConnection.failover(conn, 30_000);
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
// failover explicitly once more (failover back)
CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE, ClusterRole.STANDBY);
FailoverPhoenixConnection.failover(conn, 30_000);
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
}
/**
* Test that it times out to failover explicitly when two clusters are STANDBY.
*/
@Test(timeout = 300000)
public void testFailoverConnectionExplicitlyTimeout() throws Exception {
Connection conn = createFailoverConnection();
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.STANDBY);
try {
// failover explicitly
FailoverPhoenixConnection.failover(conn, 10_000);
fail("Should have failed since two clusters are both in STANDBY role");
} catch (FailoverSQLException e) {
LOG.info("Got expected exception when failover explicitly", e);
}
}
/**
* Test tenant specific connection creation and basic operations.
*/
@Test(timeout = 300000)
public void testTenantSpecificPhoenixConnection() throws Exception {
tableName = tableName + "Tenant";
CLUSTERS.createTenantSpecificTable(haGroup, tableName);
clientProperties.setProperty("TenantId", "mytenant");
Connection tenantConn = createFailoverConnection();
doTestBasicOperationsWithConnection(tenantConn, tableName, haGroupName);
// Make the second cluster ACTIVE will not change the wrapped connection.
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
doTestActionShouldFailBecauseOfFailover(tenantConn::createStatement);
// Application can always create new connections after cluster role transition
try (Connection newTenantConn = createFailoverConnection()) {
doTestBasicOperationsWithConnection(newTenantConn, tableName, haGroupName);
}
}
/**
* Test failover automatically happens with {@link FailoverPolicy.FailoverToActivePolicy}.
*/
@Test(timeout = 300000)
public void testStatementWithActiveFailoverPolicy() throws Exception {
clientProperties.setProperty(FailoverPolicy.PHOENIX_HA_FAILOVER_POLICY_ATTR, "active");
final Connection conn = createFailoverConnection();
final Statement stmt1 = conn.createStatement();
doTestBasicOperationsWithStatement(conn, stmt1, tableName);
// Make the second cluster the active one.
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
assertFalse(conn.isClosed());
assertTrue(stmt1.isClosed());
// Creating new statement will always work as long as there is ACTIVE cluster because the
// failover connection can failover internal wrapped phoenix connection automatically
final Statement stmt2 = conn.createStatement();
doTestBasicOperationsWithStatement(conn, stmt2, tableName);
}
@Test(timeout = 300000)
public void testFailoverMetrics() throws Exception {
Connection conn = createFailoverConnection();
// paranoid; let us just reset
PhoenixRuntime.resetMetrics(conn);
assertTrue(PhoenixRuntime.getWriteMetricInfoForMutationsSinceLastReset(conn).isEmpty());
// operation on connection: upsert once
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
doVerifyMetrics(conn, 1L);
// Failover the HA group
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
// wrapped connection should have been closed; but "conn" is not so we can still get metrics
doVerifyMetrics(conn, 1L);
// failover the connection explicitly
FailoverPhoenixConnection.failover(conn, 30_000);
doVerifyMetrics(conn, 1L);
// operation on connection: upsert once more
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
doVerifyMetrics(conn, 2L);
// reset metrics
PhoenixRuntime.resetMetrics(conn);
assertTrue(PhoenixRuntime.getWriteMetricInfoForMutationsSinceLastReset(conn).isEmpty());
// upsert once more
doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
doVerifyMetrics(conn, 1L);
// close failover connection will reset metrics
conn.close();
assertTrue(PhoenixRuntime.getWriteMetricInfoForMutationsSinceLastReset(conn).isEmpty());
}
/**
* Test transit cluster role record which should affect all the principals for a given HAGroup
*/
@Test(timeout = 300000)
public void testAllConnectionsOfHAIsAffected() throws Exception {
Connection conn = createFailoverConnection();
PhoenixConnection wrappedConn = ((FailoverPhoenixConnection) conn).getWrappedConnection();
// Create another connection with same params except different principal
// This should use same haGroup as default one and transiting that haGroup should affect this
// conn as well.
String principal = RandomStringUtils.randomAlphabetic(5);
Connection conn2 =
DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(principal), clientProperties);
PhoenixConnection wrappedConn2 = ((FailoverPhoenixConnection) conn2).getWrappedConnection();
// Following we create a new HA group and create a connection against this HA group with default
// PRINCIPAL
String haGroupName2 = haGroup.getGroupInfo().getName() + "2";
initClusterRoleRecord(haGroupName2);
Properties clientProperties2 = new Properties(clientProperties);
clientProperties2.setProperty(PHOENIX_HA_GROUP_ATTR, haGroupName2);
Connection conn3 = DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(), clientProperties2);
PhoenixConnection wrappedConn3 = ((FailoverPhoenixConnection) conn3).getWrappedConnection();
// Create another connection with haGroup2 with same principal as for conn2 with haGroup, which
// should not be
// affected by transiting haGroup
Connection conn4 =
DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(principal), clientProperties2);
PhoenixConnection wrappedConn4 = ((FailoverPhoenixConnection) conn4).getWrappedConnection();
assertFalse(wrappedConn.isClosed());
assertFalse(wrappedConn2.isClosed());
assertFalse(wrappedConn3.isClosed());
assertFalse(wrappedConn4.isClosed());
CLUSTERS.transitClusterRole(haGroup, ClusterRole.STANDBY, ClusterRole.ACTIVE);
assertTrue(wrappedConn.isClosed());
assertTrue(wrappedConn2.isClosed());
assertFalse(wrappedConn3.isClosed()); // only connection with haGroup will be closed
// irrespective of principal
assertFalse(wrappedConn4.isClosed());
}
@Test(timeout = 300000)
public void testUserPrincipal() throws Exception {
Connection conn = createFailoverConnection(); // PRINCIPAL, haGroupName
FailoverPhoenixConnection fconn = (FailoverPhoenixConnection) conn;
ConnectionQueryServices cqsi = PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup), clientProperties);
String haGroupName2 = testName.getMethodName() + RandomStringUtils.randomAlphabetic(3);
;
initClusterRoleRecord(haGroupName2);
clientProperties.setProperty(PHOENIX_HA_GROUP_ATTR, haGroupName2);
HighAvailabilityGroup haGroup2 =
getHighAvailibilityGroup(CLUSTERS.getJdbcHAUrl(), clientProperties);
Connection conn2 = DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(), clientProperties); // PRINCIPAL,haGroupName2
FailoverPhoenixConnection fconn2 = (FailoverPhoenixConnection) conn2;
ConnectionQueryServices cqsi2 = PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup2), clientProperties);
Connection conn3 =
DriverManager.getConnection(CLUSTERS.getJdbcHAUrlWithoutPrincipal(), clientProperties); // null,haGroupName2
FailoverPhoenixConnection fconn3 = (FailoverPhoenixConnection) conn3;
ConnectionQueryServices cqsi3 = PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrlWithoutPrincipal(haGroup2,
CLUSTERS.getURL(1, haGroup2.getRoleRecord().getRegistryType())), clientProperties);
clientProperties.setProperty(PHOENIX_HA_GROUP_ATTR, haGroupName);
String principal4 = RandomStringUtils.randomAlphabetic(5);
Connection conn4 =
DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(principal4), clientProperties);// principal4,
// haGroupName
FailoverPhoenixConnection fconn4 = (FailoverPhoenixConnection) conn4;
ConnectionQueryServices cqsi4 = PhoenixDriver.INSTANCE
.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup, principal4), clientProperties);
// Check wrapped connection urls
Assert.assertEquals(CLUSTERS.getJdbcUrl1(haGroup), fconn.getWrappedConnection().getURL());
Assert.assertEquals(CLUSTERS.getJdbcUrl1(haGroup2), fconn2.getWrappedConnection().getURL());
Assert.assertEquals(
CLUSTERS.getJdbcUrlWithoutPrincipal(haGroup2,
CLUSTERS.getURL(1, haGroup2.getRoleRecord().getRegistryType())),
fconn3.getWrappedConnection().getURL());
Assert.assertEquals(CLUSTERS.getJdbcUrl1(haGroup, principal4),
fconn4.getWrappedConnection().getURL());
// Check cqsi objects should be same with what we get from connections
Assert.assertEquals(HBaseTestingUtilityPair.PRINCIPAL, cqsi.getUserName());
Assert.assertSame(cqsi, fconn.getWrappedConnection().getQueryServices());
Assert.assertEquals(HBaseTestingUtilityPair.PRINCIPAL, cqsi2.getUserName());
Assert.assertSame(cqsi2, fconn2.getWrappedConnection().getQueryServices());
Assert.assertNull(cqsi3.getUserName());
Assert.assertSame(cqsi3, fconn3.getWrappedConnection().getQueryServices());
Assert.assertEquals(principal4, cqsi4.getUserName());
Assert.assertSame(cqsi4, fconn4.getWrappedConnection().getQueryServices());
}
@Test(timeout = 300000)
public void testHAGroupMappingsWithDifferentPrincipalsOnDifferentThreads() throws Exception {
int numThreads = RandomUtils.nextInt(3, 5);
List<Thread> connectionThreads = new ArrayList<>(numThreads + 4);
// Creating random number of connections one connection per thread with different principal
// Including one connection will null principal all of them will be using given haGroupName
// which is specific to test
for (int i = 0; i < numThreads; i++) {
connectionThreads.add(new Thread(() -> {
try {
createConnectionWithRandomPrincipal(false);
} catch (SQLException e) {
e.printStackTrace();
}
}));
}
// Add connections without principal
connectionThreads.add(new Thread(() -> {
try {
createConnectionWithRandomPrincipal(true);
} catch (SQLException e) {
e.printStackTrace();
}
}));
// Create multiple connections with given principal
String principal = RandomStringUtils.randomAlphabetic(3);
int numConnectionsWithSamePrincipal = 3;
for (int i = 0; i < numConnectionsWithSamePrincipal; i++) {
connectionThreads.add(new Thread(() -> {
try {
DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(principal), clientProperties);
} catch (SQLException e) {
e.printStackTrace();
}
}));
}
for (Thread connectionThread : connectionThreads) {
connectionThread.start();
}
for (Thread connectionThread : connectionThreads) {
connectionThread.join();
}
// For the given ha group of current test the value in URLS set for current haGroupInfo
// should be numThreads + 2 as all the connections created with same principal should have
// one entry in map and one extra for null principal
Assert.assertEquals(numThreads + 2, URLS.get(haGroup.getGroupInfo()).size());
}
/**
* Helper method to verify that the failover connection has expected mutation metrics.
* @param conn the failover Phoenix connection
* @param expectedUpsert number of upsert mutation sql counter
* @throws SQLException if fails to read the metrics
*/
private void doVerifyMetrics(Connection conn, long expectedUpsert) throws SQLException {
Map<String, Map<MetricType, Long>> mutation =
PhoenixRuntime.getWriteMetricInfoForMutationsSinceLastReset(conn);
assertFalse(mutation.isEmpty());
assertTrue(mutation.containsKey(tableName));
Long upsertMetric = mutation.get(tableName).get(MetricType.UPSERT_MUTATION_SQL_COUNTER);
assertEquals(expectedUpsert, upsertMetric.longValue());
assertTrue(PhoenixRuntime.getReadMetricInfoForMutationsSinceLastReset(conn).isEmpty());
}
/**
* Create a failover connection using {@link #clientProperties}.
*/
private Connection createFailoverConnection() throws SQLException {
return DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(), clientProperties);
}
@FunctionalInterface
private interface Action {
void execute() throws Exception;
}
/**
* Assert a JDBC connection is closed after failover.
*/
private static void doTestActionShouldFailBecauseOfFailover(Action action) throws Exception {
try {
action.execute();
fail("Should have failed because the connection is closed");
} catch (FailoverSQLException fe) {
LOG.info("Got expected failover exception after connection is closed.", fe);
} catch (SQLException e) {
LOG.info("Will fail the test if its cause is not FailoverSQLException", e);
assertTrue(e.getCause() instanceof FailoverSQLException);
LOG.info("Got expected failover exception after connection is closed.", e);
} // all other type of exception will fail this test.
}
private void createConnectionWithRandomPrincipal(boolean isPrincipalNull) throws SQLException {
String principal = RandomStringUtils.randomAlphabetic(5);
if (isPrincipalNull) {
DriverManager.getConnection(CLUSTERS.getJdbcHAUrlWithoutPrincipal(), clientProperties);
return;
}
DriverManager.getConnection(CLUSTERS.getJdbcHAUrl(principal), clientProperties);
}
private void initClusterRoleRecord(String haGroupName) throws Exception {
CLUSTERS.initClusterRole(haGroupName, HighAvailabilityPolicy.FAILOVER);
}
}
|
googleapis/google-cloud-java | 36,237 | java-optimization/proto-google-cloud-optimization-v1/src/main/java/com/google/cloud/optimization/v1/Waypoint.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/optimization/v1/fleet_routing.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.optimization.v1;
/**
*
*
* <pre>
* Encapsulates a waypoint. Waypoints mark arrival and departure locations of
* VisitRequests, and start and end locations of Vehicles.
* </pre>
*
* Protobuf type {@code google.cloud.optimization.v1.Waypoint}
*/
public final class Waypoint extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.optimization.v1.Waypoint)
WaypointOrBuilder {
private static final long serialVersionUID = 0L;
// Use Waypoint.newBuilder() to construct.
private Waypoint(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private Waypoint() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new Waypoint();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.optimization.v1.FleetRoutingProto
.internal_static_google_cloud_optimization_v1_Waypoint_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.optimization.v1.FleetRoutingProto
.internal_static_google_cloud_optimization_v1_Waypoint_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.optimization.v1.Waypoint.class,
com.google.cloud.optimization.v1.Waypoint.Builder.class);
}
private int locationTypeCase_ = 0;
@SuppressWarnings("serial")
private java.lang.Object locationType_;
public enum LocationTypeCase
implements
com.google.protobuf.Internal.EnumLite,
com.google.protobuf.AbstractMessage.InternalOneOfEnum {
LOCATION(1),
PLACE_ID(2),
LOCATIONTYPE_NOT_SET(0);
private final int value;
private LocationTypeCase(int value) {
this.value = value;
}
/**
* @param value The number of the enum to look for.
* @return The enum associated with the given number.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static LocationTypeCase valueOf(int value) {
return forNumber(value);
}
public static LocationTypeCase forNumber(int value) {
switch (value) {
case 1:
return LOCATION;
case 2:
return PLACE_ID;
case 0:
return LOCATIONTYPE_NOT_SET;
default:
return null;
}
}
public int getNumber() {
return this.value;
}
};
public LocationTypeCase getLocationTypeCase() {
return LocationTypeCase.forNumber(locationTypeCase_);
}
public static final int LOCATION_FIELD_NUMBER = 1;
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*
* @return Whether the location field is set.
*/
@java.lang.Override
public boolean hasLocation() {
return locationTypeCase_ == 1;
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*
* @return The location.
*/
@java.lang.Override
public com.google.cloud.optimization.v1.Location getLocation() {
if (locationTypeCase_ == 1) {
return (com.google.cloud.optimization.v1.Location) locationType_;
}
return com.google.cloud.optimization.v1.Location.getDefaultInstance();
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
@java.lang.Override
public com.google.cloud.optimization.v1.LocationOrBuilder getLocationOrBuilder() {
if (locationTypeCase_ == 1) {
return (com.google.cloud.optimization.v1.Location) locationType_;
}
return com.google.cloud.optimization.v1.Location.getDefaultInstance();
}
public static final int PLACE_ID_FIELD_NUMBER = 2;
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @return Whether the placeId field is set.
*/
public boolean hasPlaceId() {
return locationTypeCase_ == 2;
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @return The placeId.
*/
public java.lang.String getPlaceId() {
java.lang.Object ref = "";
if (locationTypeCase_ == 2) {
ref = locationType_;
}
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();
if (locationTypeCase_ == 2) {
locationType_ = s;
}
return s;
}
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @return The bytes for placeId.
*/
public com.google.protobuf.ByteString getPlaceIdBytes() {
java.lang.Object ref = "";
if (locationTypeCase_ == 2) {
ref = locationType_;
}
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
if (locationTypeCase_ == 2) {
locationType_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int SIDE_OF_ROAD_FIELD_NUMBER = 3;
private boolean sideOfRoad_ = false;
/**
*
*
* <pre>
* Indicates that the location of this waypoint is meant to have a preference
* for the vehicle to stop at a particular side of road. When you set this
* value, the route will pass through the location so that the vehicle can
* stop at the side of road that the location is biased towards from the
* center of the road. This option works only for the 'DRIVING' travel mode,
* and when the 'location_type' is set to 'location'.
* </pre>
*
* <code>bool side_of_road = 3;</code>
*
* @return The sideOfRoad.
*/
@java.lang.Override
public boolean getSideOfRoad() {
return sideOfRoad_;
}
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 (locationTypeCase_ == 1) {
output.writeMessage(1, (com.google.cloud.optimization.v1.Location) locationType_);
}
if (locationTypeCase_ == 2) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, locationType_);
}
if (sideOfRoad_ != false) {
output.writeBool(3, sideOfRoad_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (locationTypeCase_ == 1) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
1, (com.google.cloud.optimization.v1.Location) locationType_);
}
if (locationTypeCase_ == 2) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, locationType_);
}
if (sideOfRoad_ != false) {
size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, sideOfRoad_);
}
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.optimization.v1.Waypoint)) {
return super.equals(obj);
}
com.google.cloud.optimization.v1.Waypoint other =
(com.google.cloud.optimization.v1.Waypoint) obj;
if (getSideOfRoad() != other.getSideOfRoad()) return false;
if (!getLocationTypeCase().equals(other.getLocationTypeCase())) return false;
switch (locationTypeCase_) {
case 1:
if (!getLocation().equals(other.getLocation())) return false;
break;
case 2:
if (!getPlaceId().equals(other.getPlaceId())) return false;
break;
case 0:
default:
}
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();
hash = (37 * hash) + SIDE_OF_ROAD_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getSideOfRoad());
switch (locationTypeCase_) {
case 1:
hash = (37 * hash) + LOCATION_FIELD_NUMBER;
hash = (53 * hash) + getLocation().hashCode();
break;
case 2:
hash = (37 * hash) + PLACE_ID_FIELD_NUMBER;
hash = (53 * hash) + getPlaceId().hashCode();
break;
case 0:
default:
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.optimization.v1.Waypoint parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.optimization.v1.Waypoint 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.optimization.v1.Waypoint parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.optimization.v1.Waypoint 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.optimization.v1.Waypoint parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.optimization.v1.Waypoint parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.optimization.v1.Waypoint parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.optimization.v1.Waypoint 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.optimization.v1.Waypoint parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.optimization.v1.Waypoint 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.optimization.v1.Waypoint parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.optimization.v1.Waypoint 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.optimization.v1.Waypoint 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;
}
/**
*
*
* <pre>
* Encapsulates a waypoint. Waypoints mark arrival and departure locations of
* VisitRequests, and start and end locations of Vehicles.
* </pre>
*
* Protobuf type {@code google.cloud.optimization.v1.Waypoint}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.optimization.v1.Waypoint)
com.google.cloud.optimization.v1.WaypointOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.optimization.v1.FleetRoutingProto
.internal_static_google_cloud_optimization_v1_Waypoint_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.optimization.v1.FleetRoutingProto
.internal_static_google_cloud_optimization_v1_Waypoint_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.optimization.v1.Waypoint.class,
com.google.cloud.optimization.v1.Waypoint.Builder.class);
}
// Construct using com.google.cloud.optimization.v1.Waypoint.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (locationBuilder_ != null) {
locationBuilder_.clear();
}
sideOfRoad_ = false;
locationTypeCase_ = 0;
locationType_ = null;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.optimization.v1.FleetRoutingProto
.internal_static_google_cloud_optimization_v1_Waypoint_descriptor;
}
@java.lang.Override
public com.google.cloud.optimization.v1.Waypoint getDefaultInstanceForType() {
return com.google.cloud.optimization.v1.Waypoint.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.optimization.v1.Waypoint build() {
com.google.cloud.optimization.v1.Waypoint result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.optimization.v1.Waypoint buildPartial() {
com.google.cloud.optimization.v1.Waypoint result =
new com.google.cloud.optimization.v1.Waypoint(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
buildPartialOneofs(result);
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.optimization.v1.Waypoint result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000004) != 0)) {
result.sideOfRoad_ = sideOfRoad_;
}
}
private void buildPartialOneofs(com.google.cloud.optimization.v1.Waypoint result) {
result.locationTypeCase_ = locationTypeCase_;
result.locationType_ = this.locationType_;
if (locationTypeCase_ == 1 && locationBuilder_ != null) {
result.locationType_ = locationBuilder_.build();
}
}
@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.optimization.v1.Waypoint) {
return mergeFrom((com.google.cloud.optimization.v1.Waypoint) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.optimization.v1.Waypoint other) {
if (other == com.google.cloud.optimization.v1.Waypoint.getDefaultInstance()) return this;
if (other.getSideOfRoad() != false) {
setSideOfRoad(other.getSideOfRoad());
}
switch (other.getLocationTypeCase()) {
case LOCATION:
{
mergeLocation(other.getLocation());
break;
}
case PLACE_ID:
{
locationTypeCase_ = 2;
locationType_ = other.locationType_;
onChanged();
break;
}
case LOCATIONTYPE_NOT_SET:
{
break;
}
}
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 10:
{
input.readMessage(getLocationFieldBuilder().getBuilder(), extensionRegistry);
locationTypeCase_ = 1;
break;
} // case 10
case 18:
{
java.lang.String s = input.readStringRequireUtf8();
locationTypeCase_ = 2;
locationType_ = s;
break;
} // case 18
case 24:
{
sideOfRoad_ = input.readBool();
bitField0_ |= 0x00000004;
break;
} // case 24
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 locationTypeCase_ = 0;
private java.lang.Object locationType_;
public LocationTypeCase getLocationTypeCase() {
return LocationTypeCase.forNumber(locationTypeCase_);
}
public Builder clearLocationType() {
locationTypeCase_ = 0;
locationType_ = null;
onChanged();
return this;
}
private int bitField0_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.optimization.v1.Location,
com.google.cloud.optimization.v1.Location.Builder,
com.google.cloud.optimization.v1.LocationOrBuilder>
locationBuilder_;
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*
* @return Whether the location field is set.
*/
@java.lang.Override
public boolean hasLocation() {
return locationTypeCase_ == 1;
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*
* @return The location.
*/
@java.lang.Override
public com.google.cloud.optimization.v1.Location getLocation() {
if (locationBuilder_ == null) {
if (locationTypeCase_ == 1) {
return (com.google.cloud.optimization.v1.Location) locationType_;
}
return com.google.cloud.optimization.v1.Location.getDefaultInstance();
} else {
if (locationTypeCase_ == 1) {
return locationBuilder_.getMessage();
}
return com.google.cloud.optimization.v1.Location.getDefaultInstance();
}
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
public Builder setLocation(com.google.cloud.optimization.v1.Location value) {
if (locationBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
locationType_ = value;
onChanged();
} else {
locationBuilder_.setMessage(value);
}
locationTypeCase_ = 1;
return this;
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
public Builder setLocation(com.google.cloud.optimization.v1.Location.Builder builderForValue) {
if (locationBuilder_ == null) {
locationType_ = builderForValue.build();
onChanged();
} else {
locationBuilder_.setMessage(builderForValue.build());
}
locationTypeCase_ = 1;
return this;
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
public Builder mergeLocation(com.google.cloud.optimization.v1.Location value) {
if (locationBuilder_ == null) {
if (locationTypeCase_ == 1
&& locationType_ != com.google.cloud.optimization.v1.Location.getDefaultInstance()) {
locationType_ =
com.google.cloud.optimization.v1.Location.newBuilder(
(com.google.cloud.optimization.v1.Location) locationType_)
.mergeFrom(value)
.buildPartial();
} else {
locationType_ = value;
}
onChanged();
} else {
if (locationTypeCase_ == 1) {
locationBuilder_.mergeFrom(value);
} else {
locationBuilder_.setMessage(value);
}
}
locationTypeCase_ = 1;
return this;
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
public Builder clearLocation() {
if (locationBuilder_ == null) {
if (locationTypeCase_ == 1) {
locationTypeCase_ = 0;
locationType_ = null;
onChanged();
}
} else {
if (locationTypeCase_ == 1) {
locationTypeCase_ = 0;
locationType_ = null;
}
locationBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
public com.google.cloud.optimization.v1.Location.Builder getLocationBuilder() {
return getLocationFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
@java.lang.Override
public com.google.cloud.optimization.v1.LocationOrBuilder getLocationOrBuilder() {
if ((locationTypeCase_ == 1) && (locationBuilder_ != null)) {
return locationBuilder_.getMessageOrBuilder();
} else {
if (locationTypeCase_ == 1) {
return (com.google.cloud.optimization.v1.Location) locationType_;
}
return com.google.cloud.optimization.v1.Location.getDefaultInstance();
}
}
/**
*
*
* <pre>
* A point specified using geographic coordinates, including an optional
* heading.
* </pre>
*
* <code>.google.cloud.optimization.v1.Location location = 1;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.optimization.v1.Location,
com.google.cloud.optimization.v1.Location.Builder,
com.google.cloud.optimization.v1.LocationOrBuilder>
getLocationFieldBuilder() {
if (locationBuilder_ == null) {
if (!(locationTypeCase_ == 1)) {
locationType_ = com.google.cloud.optimization.v1.Location.getDefaultInstance();
}
locationBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.optimization.v1.Location,
com.google.cloud.optimization.v1.Location.Builder,
com.google.cloud.optimization.v1.LocationOrBuilder>(
(com.google.cloud.optimization.v1.Location) locationType_,
getParentForChildren(),
isClean());
locationType_ = null;
}
locationTypeCase_ = 1;
onChanged();
return locationBuilder_;
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @return Whether the placeId field is set.
*/
@java.lang.Override
public boolean hasPlaceId() {
return locationTypeCase_ == 2;
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @return The placeId.
*/
@java.lang.Override
public java.lang.String getPlaceId() {
java.lang.Object ref = "";
if (locationTypeCase_ == 2) {
ref = locationType_;
}
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (locationTypeCase_ == 2) {
locationType_ = s;
}
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @return The bytes for placeId.
*/
@java.lang.Override
public com.google.protobuf.ByteString getPlaceIdBytes() {
java.lang.Object ref = "";
if (locationTypeCase_ == 2) {
ref = locationType_;
}
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
if (locationTypeCase_ == 2) {
locationType_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @param value The placeId to set.
* @return This builder for chaining.
*/
public Builder setPlaceId(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
locationTypeCase_ = 2;
locationType_ = value;
onChanged();
return this;
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearPlaceId() {
if (locationTypeCase_ == 2) {
locationTypeCase_ = 0;
locationType_ = null;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* The POI Place ID associated with the waypoint.
* </pre>
*
* <code>string place_id = 2;</code>
*
* @param value The bytes for placeId to set.
* @return This builder for chaining.
*/
public Builder setPlaceIdBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
locationTypeCase_ = 2;
locationType_ = value;
onChanged();
return this;
}
private boolean sideOfRoad_;
/**
*
*
* <pre>
* Indicates that the location of this waypoint is meant to have a preference
* for the vehicle to stop at a particular side of road. When you set this
* value, the route will pass through the location so that the vehicle can
* stop at the side of road that the location is biased towards from the
* center of the road. This option works only for the 'DRIVING' travel mode,
* and when the 'location_type' is set to 'location'.
* </pre>
*
* <code>bool side_of_road = 3;</code>
*
* @return The sideOfRoad.
*/
@java.lang.Override
public boolean getSideOfRoad() {
return sideOfRoad_;
}
/**
*
*
* <pre>
* Indicates that the location of this waypoint is meant to have a preference
* for the vehicle to stop at a particular side of road. When you set this
* value, the route will pass through the location so that the vehicle can
* stop at the side of road that the location is biased towards from the
* center of the road. This option works only for the 'DRIVING' travel mode,
* and when the 'location_type' is set to 'location'.
* </pre>
*
* <code>bool side_of_road = 3;</code>
*
* @param value The sideOfRoad to set.
* @return This builder for chaining.
*/
public Builder setSideOfRoad(boolean value) {
sideOfRoad_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Indicates that the location of this waypoint is meant to have a preference
* for the vehicle to stop at a particular side of road. When you set this
* value, the route will pass through the location so that the vehicle can
* stop at the side of road that the location is biased towards from the
* center of the road. This option works only for the 'DRIVING' travel mode,
* and when the 'location_type' is set to 'location'.
* </pre>
*
* <code>bool side_of_road = 3;</code>
*
* @return This builder for chaining.
*/
public Builder clearSideOfRoad() {
bitField0_ = (bitField0_ & ~0x00000004);
sideOfRoad_ = false;
onChanged();
return this;
}
@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.optimization.v1.Waypoint)
}
// @@protoc_insertion_point(class_scope:google.cloud.optimization.v1.Waypoint)
private static final com.google.cloud.optimization.v1.Waypoint DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.optimization.v1.Waypoint();
}
public static com.google.cloud.optimization.v1.Waypoint getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<Waypoint> PARSER =
new com.google.protobuf.AbstractParser<Waypoint>() {
@java.lang.Override
public Waypoint 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<Waypoint> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<Waypoint> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.optimization.v1.Waypoint getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,242 | java-contact-center-insights/proto-google-cloud-contact-center-insights-v1/src/main/java/com/google/cloud/contactcenterinsights/v1/ListViewsResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/contactcenterinsights/v1/contact_center_insights.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.contactcenterinsights.v1;
/**
*
*
* <pre>
* The response of listing views.
* </pre>
*
* Protobuf type {@code google.cloud.contactcenterinsights.v1.ListViewsResponse}
*/
public final class ListViewsResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.contactcenterinsights.v1.ListViewsResponse)
ListViewsResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListViewsResponse.newBuilder() to construct.
private ListViewsResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListViewsResponse() {
views_ = java.util.Collections.emptyList();
nextPageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListViewsResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.contactcenterinsights.v1.ContactCenterInsightsProto
.internal_static_google_cloud_contactcenterinsights_v1_ListViewsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.contactcenterinsights.v1.ContactCenterInsightsProto
.internal_static_google_cloud_contactcenterinsights_v1_ListViewsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.contactcenterinsights.v1.ListViewsResponse.class,
com.google.cloud.contactcenterinsights.v1.ListViewsResponse.Builder.class);
}
public static final int VIEWS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.contactcenterinsights.v1.View> views_;
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.contactcenterinsights.v1.View> getViewsList() {
return views_;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.cloud.contactcenterinsights.v1.ViewOrBuilder>
getViewsOrBuilderList() {
return views_;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
@java.lang.Override
public int getViewsCount() {
return views_.size();
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
@java.lang.Override
public com.google.cloud.contactcenterinsights.v1.View getViews(int index) {
return views_.get(index);
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
@java.lang.Override
public com.google.cloud.contactcenterinsights.v1.ViewOrBuilder getViewsOrBuilder(int index) {
return views_.get(index);
}
public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
@java.lang.Override
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
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();
nextPageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 {
for (int i = 0; i < views_.size(); i++) {
output.writeMessage(1, views_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < views_.size(); i++) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, views_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_);
}
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.contactcenterinsights.v1.ListViewsResponse)) {
return super.equals(obj);
}
com.google.cloud.contactcenterinsights.v1.ListViewsResponse other =
(com.google.cloud.contactcenterinsights.v1.ListViewsResponse) obj;
if (!getViewsList().equals(other.getViewsList())) return false;
if (!getNextPageToken().equals(other.getNextPageToken())) 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 (getViewsCount() > 0) {
hash = (37 * hash) + VIEWS_FIELD_NUMBER;
hash = (53 * hash) + getViewsList().hashCode();
}
hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getNextPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse 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.contactcenterinsights.v1.ListViewsResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse 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.contactcenterinsights.v1.ListViewsResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse 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.contactcenterinsights.v1.ListViewsResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse 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.contactcenterinsights.v1.ListViewsResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse 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.contactcenterinsights.v1.ListViewsResponse 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;
}
/**
*
*
* <pre>
* The response of listing views.
* </pre>
*
* Protobuf type {@code google.cloud.contactcenterinsights.v1.ListViewsResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.contactcenterinsights.v1.ListViewsResponse)
com.google.cloud.contactcenterinsights.v1.ListViewsResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.contactcenterinsights.v1.ContactCenterInsightsProto
.internal_static_google_cloud_contactcenterinsights_v1_ListViewsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.contactcenterinsights.v1.ContactCenterInsightsProto
.internal_static_google_cloud_contactcenterinsights_v1_ListViewsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.contactcenterinsights.v1.ListViewsResponse.class,
com.google.cloud.contactcenterinsights.v1.ListViewsResponse.Builder.class);
}
// Construct using com.google.cloud.contactcenterinsights.v1.ListViewsResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (viewsBuilder_ == null) {
views_ = java.util.Collections.emptyList();
} else {
views_ = null;
viewsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
nextPageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.contactcenterinsights.v1.ContactCenterInsightsProto
.internal_static_google_cloud_contactcenterinsights_v1_ListViewsResponse_descriptor;
}
@java.lang.Override
public com.google.cloud.contactcenterinsights.v1.ListViewsResponse getDefaultInstanceForType() {
return com.google.cloud.contactcenterinsights.v1.ListViewsResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.contactcenterinsights.v1.ListViewsResponse build() {
com.google.cloud.contactcenterinsights.v1.ListViewsResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.contactcenterinsights.v1.ListViewsResponse buildPartial() {
com.google.cloud.contactcenterinsights.v1.ListViewsResponse result =
new com.google.cloud.contactcenterinsights.v1.ListViewsResponse(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.contactcenterinsights.v1.ListViewsResponse result) {
if (viewsBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
views_ = java.util.Collections.unmodifiableList(views_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.views_ = views_;
} else {
result.views_ = viewsBuilder_.build();
}
}
private void buildPartial0(com.google.cloud.contactcenterinsights.v1.ListViewsResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.nextPageToken_ = nextPageToken_;
}
}
@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.contactcenterinsights.v1.ListViewsResponse) {
return mergeFrom((com.google.cloud.contactcenterinsights.v1.ListViewsResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.contactcenterinsights.v1.ListViewsResponse other) {
if (other == com.google.cloud.contactcenterinsights.v1.ListViewsResponse.getDefaultInstance())
return this;
if (viewsBuilder_ == null) {
if (!other.views_.isEmpty()) {
if (views_.isEmpty()) {
views_ = other.views_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureViewsIsMutable();
views_.addAll(other.views_);
}
onChanged();
}
} else {
if (!other.views_.isEmpty()) {
if (viewsBuilder_.isEmpty()) {
viewsBuilder_.dispose();
viewsBuilder_ = null;
views_ = other.views_;
bitField0_ = (bitField0_ & ~0x00000001);
viewsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getViewsFieldBuilder()
: null;
} else {
viewsBuilder_.addAllMessages(other.views_);
}
}
}
if (!other.getNextPageToken().isEmpty()) {
nextPageToken_ = other.nextPageToken_;
bitField0_ |= 0x00000002;
onChanged();
}
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 10:
{
com.google.cloud.contactcenterinsights.v1.View m =
input.readMessage(
com.google.cloud.contactcenterinsights.v1.View.parser(), extensionRegistry);
if (viewsBuilder_ == null) {
ensureViewsIsMutable();
views_.add(m);
} else {
viewsBuilder_.addMessage(m);
}
break;
} // case 10
case 18:
{
nextPageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
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.contactcenterinsights.v1.View> views_ =
java.util.Collections.emptyList();
private void ensureViewsIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
views_ = new java.util.ArrayList<com.google.cloud.contactcenterinsights.v1.View>(views_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.contactcenterinsights.v1.View,
com.google.cloud.contactcenterinsights.v1.View.Builder,
com.google.cloud.contactcenterinsights.v1.ViewOrBuilder>
viewsBuilder_;
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public java.util.List<com.google.cloud.contactcenterinsights.v1.View> getViewsList() {
if (viewsBuilder_ == null) {
return java.util.Collections.unmodifiableList(views_);
} else {
return viewsBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public int getViewsCount() {
if (viewsBuilder_ == null) {
return views_.size();
} else {
return viewsBuilder_.getCount();
}
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public com.google.cloud.contactcenterinsights.v1.View getViews(int index) {
if (viewsBuilder_ == null) {
return views_.get(index);
} else {
return viewsBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder setViews(int index, com.google.cloud.contactcenterinsights.v1.View value) {
if (viewsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureViewsIsMutable();
views_.set(index, value);
onChanged();
} else {
viewsBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder setViews(
int index, com.google.cloud.contactcenterinsights.v1.View.Builder builderForValue) {
if (viewsBuilder_ == null) {
ensureViewsIsMutable();
views_.set(index, builderForValue.build());
onChanged();
} else {
viewsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder addViews(com.google.cloud.contactcenterinsights.v1.View value) {
if (viewsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureViewsIsMutable();
views_.add(value);
onChanged();
} else {
viewsBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder addViews(int index, com.google.cloud.contactcenterinsights.v1.View value) {
if (viewsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureViewsIsMutable();
views_.add(index, value);
onChanged();
} else {
viewsBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder addViews(
com.google.cloud.contactcenterinsights.v1.View.Builder builderForValue) {
if (viewsBuilder_ == null) {
ensureViewsIsMutable();
views_.add(builderForValue.build());
onChanged();
} else {
viewsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder addViews(
int index, com.google.cloud.contactcenterinsights.v1.View.Builder builderForValue) {
if (viewsBuilder_ == null) {
ensureViewsIsMutable();
views_.add(index, builderForValue.build());
onChanged();
} else {
viewsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder addAllViews(
java.lang.Iterable<? extends com.google.cloud.contactcenterinsights.v1.View> values) {
if (viewsBuilder_ == null) {
ensureViewsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, views_);
onChanged();
} else {
viewsBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder clearViews() {
if (viewsBuilder_ == null) {
views_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
viewsBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public Builder removeViews(int index) {
if (viewsBuilder_ == null) {
ensureViewsIsMutable();
views_.remove(index);
onChanged();
} else {
viewsBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public com.google.cloud.contactcenterinsights.v1.View.Builder getViewsBuilder(int index) {
return getViewsFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public com.google.cloud.contactcenterinsights.v1.ViewOrBuilder getViewsOrBuilder(int index) {
if (viewsBuilder_ == null) {
return views_.get(index);
} else {
return viewsBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public java.util.List<? extends com.google.cloud.contactcenterinsights.v1.ViewOrBuilder>
getViewsOrBuilderList() {
if (viewsBuilder_ != null) {
return viewsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(views_);
}
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public com.google.cloud.contactcenterinsights.v1.View.Builder addViewsBuilder() {
return getViewsFieldBuilder()
.addBuilder(com.google.cloud.contactcenterinsights.v1.View.getDefaultInstance());
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public com.google.cloud.contactcenterinsights.v1.View.Builder addViewsBuilder(int index) {
return getViewsFieldBuilder()
.addBuilder(index, com.google.cloud.contactcenterinsights.v1.View.getDefaultInstance());
}
/**
*
*
* <pre>
* The views that match the request.
* </pre>
*
* <code>repeated .google.cloud.contactcenterinsights.v1.View views = 1;</code>
*/
public java.util.List<com.google.cloud.contactcenterinsights.v1.View.Builder>
getViewsBuilderList() {
return getViewsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.contactcenterinsights.v1.View,
com.google.cloud.contactcenterinsights.v1.View.Builder,
com.google.cloud.contactcenterinsights.v1.ViewOrBuilder>
getViewsFieldBuilder() {
if (viewsBuilder_ == null) {
viewsBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.contactcenterinsights.v1.View,
com.google.cloud.contactcenterinsights.v1.View.Builder,
com.google.cloud.contactcenterinsights.v1.ViewOrBuilder>(
views_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
views_ = null;
}
return viewsBuilder_;
}
private java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
nextPageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearNextPageToken() {
nextPageToken_ = getDefaultInstance().getNextPageToken();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The bytes for nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.contactcenterinsights.v1.ListViewsResponse)
}
// @@protoc_insertion_point(class_scope:google.cloud.contactcenterinsights.v1.ListViewsResponse)
private static final com.google.cloud.contactcenterinsights.v1.ListViewsResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.contactcenterinsights.v1.ListViewsResponse();
}
public static com.google.cloud.contactcenterinsights.v1.ListViewsResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListViewsResponse> PARSER =
new com.google.protobuf.AbstractParser<ListViewsResponse>() {
@java.lang.Override
public ListViewsResponse 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<ListViewsResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListViewsResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.contactcenterinsights.v1.ListViewsResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/ofbiz-framework | 36,444 | applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java | /*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
package org.apache.ofbiz.product.store;
import java.math.BigDecimal;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.UtilHttp;
import org.apache.ofbiz.base.util.UtilMisc;
import org.apache.ofbiz.base.util.UtilValidate;
import org.apache.ofbiz.common.geo.GeoWorker;
import org.apache.ofbiz.entity.Delegator;
import org.apache.ofbiz.entity.GenericEntityException;
import org.apache.ofbiz.entity.GenericValue;
import org.apache.ofbiz.entity.util.EntityQuery;
import org.apache.ofbiz.entity.util.EntityUtil;
import org.apache.ofbiz.party.contact.ContactMechWorker;
import org.apache.ofbiz.product.config.ProductConfigWrapper;
import org.apache.ofbiz.product.product.ProductWorker;
import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ServiceUtil;
import org.apache.ofbiz.webapp.website.WebSiteWorker;
/**
* ProductStoreWorker - Worker class for store related functionality
*/
public final class ProductStoreWorker {
private static final String MODULE = ProductStoreWorker.class.getName();
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
private ProductStoreWorker() { }
public static GenericValue getProductStore(String productStoreId, Delegator delegator) {
if (productStoreId == null || delegator == null) {
return null;
}
GenericValue productStore = null;
try {
productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Problem getting ProductStore entity", MODULE);
}
return productStore;
}
public static GenericValue getProductStore(ServletRequest request) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
String productStoreId = ProductStoreWorker.getProductStoreId(request);
return ProductStoreWorker.getProductStore(productStoreId, delegator);
}
public static String getProductStoreId(ServletRequest request) {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpSession session = httpRequest.getSession(false);
if (session != null && session.getAttribute("productStoreId") != null) {
return (String) session.getAttribute("productStoreId");
} else {
GenericValue webSite = WebSiteWorker.getWebSite(httpRequest);
if (webSite != null) {
String productStoreId = webSite.getString("productStoreId");
// might be nice to do this, but not needed and has a problem with dependencies: setSessionProductStore(productStoreId, httpRequest);
return productStoreId;
}
}
return null;
}
public static String getStoreCurrencyUomId(HttpServletRequest request) {
GenericValue productStore = getProductStore(request);
if (UtilValidate.isEmpty(productStore)) {
Debug.logError(
"No product store found in request, cannot set CurrencyUomId!", MODULE);
return null;
} else {
return UtilHttp.getCurrencyUom(request.getSession(), productStore.getString("defaultCurrencyUomId"));
}
}
public static Locale getStoreLocale(HttpServletRequest request) {
GenericValue productStore = getProductStore(request);
if (UtilValidate.isEmpty(productStore)) {
Debug.logError(
"No product store found in request, cannot set locale!", MODULE);
return null;
} else {
return UtilHttp.getLocale(request, request.getSession(), productStore.getString("defaultLocaleString"));
}
}
public static TimeZone getStoreTimeZone(HttpServletRequest request) {
GenericValue productStore = getProductStore(request);
if (UtilValidate.isEmpty(productStore)) {
Debug.logError("No product store found in request, cannot set timezone!", MODULE);
return null;
} else {
return UtilHttp.getTimeZone(request, request.getSession(), productStore.getString("defaultTimeZoneString"));
}
}
public static String determineSingleFacilityForStore(Delegator delegator, String productStoreId) {
GenericValue productStore = null;
try {
productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
}
if (productStore != null) {
if ("Y".equalsIgnoreCase(productStore.getString("oneInventoryFacility"))) {
return productStore.getString("inventoryFacilityId");
}
}
return null;
}
public static boolean autoSaveCart(Delegator delegator, String productStoreId) {
return autoSaveCart(getProductStore(productStoreId, delegator));
}
public static boolean autoSaveCart(GenericValue productStore) {
return productStore == null ? false : "Y".equalsIgnoreCase(productStore.getString("autoSaveCart"));
}
public static String getProductStorePayToPartyId(String productStoreId, Delegator delegator) {
return getProductStorePayToPartyId(getProductStore(productStoreId, delegator));
}
public static String getProductStorePayToPartyId(GenericValue productStore) {
String payToPartyId = "Company"; // default value
if (productStore != null && productStore.get("payToPartyId") != null) {
payToPartyId = productStore.getString("payToPartyId");
}
return payToPartyId;
}
public static String getProductStorePaymentProperties(ServletRequest request, String paymentMethodTypeId, String paymentServiceTypeEnumId,
boolean anyServiceType) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
String productStoreId = ProductStoreWorker.getProductStoreId(request);
return ProductStoreWorker.getProductStorePaymentProperties(delegator, productStoreId, paymentMethodTypeId, paymentServiceTypeEnumId,
anyServiceType);
}
public static String getProductStorePaymentProperties(Delegator delegator, String productStoreId, String paymentMethodTypeId,
String paymentServiceTypeEnumId, boolean anyServiceType) {
GenericValue setting = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStoreId, paymentMethodTypeId,
paymentServiceTypeEnumId, anyServiceType);
String payProps = "payment.properties";
if (setting != null && setting.get("paymentPropertiesPath") != null) {
payProps = setting.getString("paymentPropertiesPath");
}
return payProps;
}
public static GenericValue getProductStorePaymentSetting(Delegator delegator, String productStoreId, String paymentMethodTypeId,
String paymentServiceTypeEnumId, boolean anyServiceType) {
GenericValue storePayment = null;
try {
storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId,
"paymentMethodTypeId", paymentMethodTypeId, "paymentServiceTypeEnumId", paymentServiceTypeEnumId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Problems looking up store payment settings", MODULE);
}
if (anyServiceType) {
if (storePayment == null) {
try {
storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId,
"paymentMethodTypeId", paymentMethodTypeId).queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, "Problems looking up store payment settings", MODULE);
}
}
if (storePayment == null) {
try {
storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId).queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, "Problems looking up store payment settings", MODULE);
}
}
}
return storePayment;
}
public static List<GenericValue> getProductStoreShipmentMethods(Delegator delegator, String productStoreId,
String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId) {
// check for an external service call
List<GenericValue> storeShipMethods = null;
try {
storeShipMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMeth")
.where("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId,
"partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId)
.cache(true)
.queryList();
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
}
return storeShipMethods;
}
public static GenericValue getProductStoreShipmentMethod(Delegator delegator, String productStoreId,
String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId) {
// TODO: selecting the first record is a far from optimal solution but, since the productStoreShipmentMethod
// is currently used to get the service name to get the online estimate, this should not be a huge deal for now.
return EntityUtil.getFirst(getProductStoreShipmentMethods(delegator, productStoreId, shipmentMethodTypeId, carrierPartyId,
carrierRoleTypeId));
}
public static List<GenericValue> getAvailableStoreShippingMethods(Delegator delegator, String productStoreId, GenericValue shippingAddress,
List<BigDecimal> itemSizes, Map<String, BigDecimal> featureIdMap, BigDecimal weight, BigDecimal orderTotal) {
if (featureIdMap == null) {
featureIdMap = new HashMap<>();
}
List<GenericValue> shippingMethods = null;
try {
shippingMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMethView").where("productStoreId",
productStoreId).orderBy("sequenceNumber").cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get ProductStore shipping methods", MODULE);
return null;
}
// clone the list for concurrent modification
List<GenericValue> returnShippingMethods = UtilMisc.makeListWritable(shippingMethods);
if (shippingMethods != null) {
for (GenericValue method: shippingMethods) {
// test min/max weight first
BigDecimal minWeight = method.getBigDecimal("minWeight");
BigDecimal maxWeight = method.getBigDecimal("maxWeight");
if (minWeight != null && minWeight.compareTo(BigDecimal.ZERO) > 0 && minWeight.compareTo(weight) > 0) {
returnShippingMethods.remove(method);
continue;
}
if (maxWeight != null && maxWeight.compareTo(BigDecimal.ZERO) > 0 && maxWeight.compareTo(weight) < 0) {
returnShippingMethods.remove(method);
continue;
}
// test order total
BigDecimal minTotal = method.getBigDecimal("minTotal");
BigDecimal maxTotal = method.getBigDecimal("maxTotal");
if (minTotal != null && minTotal.compareTo(BigDecimal.ZERO) > 0 && minTotal.compareTo(orderTotal) > 0) {
returnShippingMethods.remove(method);
continue;
}
if (maxTotal != null && maxTotal.compareTo(BigDecimal.ZERO) > 0 && maxTotal.compareTo(orderTotal) < 0) {
returnShippingMethods.remove(method);
continue;
}
// test product sizes
BigDecimal minSize = method.getBigDecimal("minSize");
BigDecimal maxSize = method.getBigDecimal("maxSize");
if (minSize != null && minSize.compareTo(BigDecimal.ZERO) > 0) {
boolean allMatch = false;
if (itemSizes != null) {
allMatch = true;
for (BigDecimal size: itemSizes) {
if (size.compareTo(minSize) < 0) {
allMatch = false;
}
}
}
if (!allMatch) {
returnShippingMethods.remove(method);
continue;
}
}
if (maxSize != null && maxSize.compareTo(BigDecimal.ZERO) > 0) {
boolean allMatch = false;
if (itemSizes != null) {
allMatch = true;
for (BigDecimal size: itemSizes) {
if (size.compareTo(maxSize) > 0) {
allMatch = false;
}
}
}
if (!allMatch) {
returnShippingMethods.remove(method);
continue;
}
}
// check USPS address
String allowUspsAddr = method.getString("allowUspsAddr");
String requireUspsAddr = method.getString("requireUspsAddr");
boolean isUspsAddress = ContactMechWorker.isUspsAddress(shippingAddress);
if ("N".equals(allowUspsAddr) && isUspsAddress) {
returnShippingMethods.remove(method);
continue;
}
if ("Y".equals(requireUspsAddr) && !isUspsAddress) {
returnShippingMethods.remove(method);
continue;
}
// check company address
String companyPartyId = method.getString("companyPartyId");
String allowCompanyAddr = method.getString("allowCompanyAddr");
String requireCompanyAddr = method.getString("requireCompanyAddr");
boolean isCompanyAddress = ContactMechWorker.isCompanyAddress(shippingAddress, companyPartyId);
if ("N".equals(allowCompanyAddr) && isCompanyAddress) {
returnShippingMethods.remove(method);
continue;
}
if ("Y".equals(requireCompanyAddr) && !isCompanyAddress) {
returnShippingMethods.remove(method);
continue;
}
// check the items excluded from shipping
String includeFreeShipping = method.getString("includeNoChargeItems");
if (includeFreeShipping != null && "N".equalsIgnoreCase(includeFreeShipping)) {
if (UtilValidate.isEmpty(itemSizes) && orderTotal.compareTo(BigDecimal.ZERO) == 0) {
returnShippingMethods.remove(method);
continue;
}
}
// check the geos
String includeGeoId = method.getString("includeGeoId");
String excludeGeoId = method.getString("excludeGeoId");
if (UtilValidate.isNotEmpty(includeGeoId) || UtilValidate.isNotEmpty(excludeGeoId)) {
if (shippingAddress == null) {
returnShippingMethods.remove(method);
continue;
}
}
if (UtilValidate.isNotEmpty(includeGeoId)) {
List<GenericValue> includeGeoGroup = GeoWorker.expandGeoGroup(includeGeoId, delegator);
if (!GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("countryGeoId"), delegator)
&& !GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator)
&& !GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) {
// not in required included geos
returnShippingMethods.remove(method);
continue;
}
}
if (UtilValidate.isNotEmpty(excludeGeoId)) {
List<GenericValue> excludeGeoGroup = GeoWorker.expandGeoGroup(excludeGeoId, delegator);
if (GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("countryGeoId"), delegator)
|| GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator)
|| GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) {
// in excluded geos
returnShippingMethods.remove(method);
continue;
}
}
// check the features
String includeFeatures = method.getString("includeFeatureGroup");
String excludeFeatures = method.getString("excludeFeatureGroup");
if (UtilValidate.isNotEmpty(includeFeatures)) {
List<GenericValue> includedFeatures = null;
try {
includedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId",
includeFeatures).cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + includeFeatures, MODULE);
}
if (includedFeatures != null) {
boolean foundOne = false;
for (GenericValue appl: includedFeatures) {
if (featureIdMap.containsKey(appl.getString("productFeatureId"))) {
foundOne = true;
break;
}
}
if (!foundOne) {
returnShippingMethods.remove(method);
continue;
}
}
}
if (UtilValidate.isNotEmpty(excludeFeatures)) {
List<GenericValue> excludedFeatures = null;
try {
excludedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId",
excludeFeatures).cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, MODULE);
}
if (excludedFeatures != null) {
for (GenericValue appl: excludedFeatures) {
if (featureIdMap.containsKey(appl.getString("productFeatureId"))) {
returnShippingMethods.remove(method);
continue;
}
}
}
}
}
}
return returnShippingMethods;
}
public static ProductStoreSurveyWrapper getRandomSurveyWrapper(HttpServletRequest request, String groupName) {
GenericValue productStore = getProductStore(request);
HttpSession session = request.getSession();
if (productStore == null) {
return null;
}
GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
if (userLogin == null) {
userLogin = (GenericValue) session.getAttribute("autoUserLogin");
}
String partyId = userLogin != null ? userLogin.getString("partyId") : null;
String origParamMapId = UtilHttp.stashParameterMap(request);
Map<String, Object> passThruFields = UtilMisc.<String, Object>toMap("_ORIG_PARAM_MAP_ID_", origParamMapId);
return getRandomSurveyWrapper(productStore.getDelegator(), productStore.getString("productStoreId"), groupName, partyId, passThruFields);
}
public static ProductStoreSurveyWrapper getRandomSurveyWrapper(Delegator delegator, String productStoreId, String groupName, String
partyId, Map<String, Object> passThruFields) {
List<GenericValue> randomSurveys = getSurveys(delegator, productStoreId, groupName, null, "RANDOM_POLL", null);
if (UtilValidate.isNotEmpty(randomSurveys)) {
int index = SECURE_RANDOM.nextInt(randomSurveys.size());
GenericValue appl = randomSurveys.get(index);
return new ProductStoreSurveyWrapper(appl, partyId, passThruFields);
} else {
return null;
}
}
public static List<GenericValue> getProductSurveys(Delegator delegator, String productStoreId, String productId, String surveyApplTypeId) {
return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId, null);
}
public static List<GenericValue> getProductSurveys(Delegator delegator, String productStoreId, String productId, String surveyApplTypeId,
String parentProductId) {
return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId, parentProductId);
}
public static List<GenericValue> getSurveys(Delegator delegator, String productStoreId, String groupName, String productId, String
surveyApplTypeId, String parentProductId) {
List<GenericValue> surveys = new LinkedList<>();
List<GenericValue> storeSurveys = null;
try {
storeSurveys = EntityQuery.use(delegator).from("ProductStoreSurveyAppl").where("productStoreId", productStoreId, "surveyApplTypeId",
surveyApplTypeId).orderBy("sequenceNum").cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get ProductStoreSurveyAppl for store : " + productStoreId, MODULE);
return surveys;
}
// limit by date
storeSurveys = EntityUtil.filterByDate(storeSurveys);
// limit based on group name
if (UtilValidate.isNotEmpty(groupName)) {
storeSurveys = EntityUtil.filterByAnd(storeSurveys, UtilMisc.toMap("groupName", groupName));
}
Debug.logInfo("getSurvey for product " + productId, MODULE);
// limit by product
if (UtilValidate.isNotEmpty(productId) && UtilValidate.isNotEmpty(storeSurveys)) {
for (GenericValue surveyAppl: storeSurveys) {
GenericValue product = null;
String virtualProductId = null;
// if the item is a variant, get its virtual productId
try {
product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne();
if ((product != null) && ("Y".equals(product.get("isVariant")))) {
if (parentProductId != null) {
virtualProductId = parentProductId;
} else {
virtualProductId = ProductWorker.getVariantVirtualId(product);
}
Debug.logInfo("getSurvey for virtual product " + virtualProductId, MODULE);
}
} catch (GenericEntityException e) {
Debug.logError(e, "Problem finding product from productId " + productId, MODULE);
}
// use survey if productId or virtualProductId of the variant product is in the ProductStoreSurveyAppl
if (surveyAppl.get("productId") != null) {
if (surveyAppl.get("productId").equals(productId)) {
surveys.add(surveyAppl);
} else if ((virtualProductId != null) && (surveyAppl.getString("productId").equals(virtualProductId))) {
surveys.add(surveyAppl);
}
} else if (surveyAppl.get("productCategoryId") != null) {
List<GenericValue> categoryMembers = null;
try {
categoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId",
surveyAppl.get("productCategoryId")).cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get ProductCategoryMember records for survey application : " + surveyAppl, MODULE);
}
if (categoryMembers != null) {
for (GenericValue member: categoryMembers) {
if (productId != null && productId.equals(member.getString("productId"))) {
surveys.add(surveyAppl);
break;
} else if ((virtualProductId != null) && (virtualProductId.equals(member.getString("productId")))) {
// similarly, check if virtual productId is in category
surveys.add(surveyAppl);
break;
}
}
}
}
}
} else if (storeSurveys != null) {
surveys.addAll(storeSurveys);
}
return surveys;
}
/** Returns the number of responses for this survey by party */
public static int checkSurveyResponse(HttpServletRequest request, String surveyId) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
String productStoreId = getProductStoreId(request);
if (userLogin == null) {
return -1;
}
return checkSurveyResponse(delegator, userLogin.getString("partyId"), productStoreId, surveyId);
}
/** Returns the number of responses for this survey by party */
public static int checkSurveyResponse(Delegator delegator, String partyId, String productStoreId, String surveyId) {
if (delegator == null || partyId == null || productStoreId == null) {
return -1;
}
List<GenericValue> surveyResponse = null;
try {
surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyId", surveyId, "partyId", partyId).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
return -1;
}
if (UtilValidate.isEmpty(surveyResponse)) {
return 0;
} else {
return surveyResponse.size();
}
}
public static boolean isStoreInventoryRequired(ServletRequest request, GenericValue product) {
return isStoreInventoryRequiredAndAvailable(request, product, null, Boolean.TRUE, null);
}
public static boolean isStoreInventoryAvailable(ServletRequest request, GenericValue product, BigDecimal quantity) {
return isStoreInventoryRequiredAndAvailable(request, product, quantity, null, Boolean.TRUE);
}
/**
* This method is used in the showcart pages to determine whether or not to show the inventory message and
* in the productdetail pages to determine whether or not to show the item as out of stock.
* @param request ServletRequest (or HttpServletRequest of course)
* @param product GenericValue representing the product in question
* @param quantity Quantity desired.
* @param wantRequired If true then inventory required must be true for the result to be true, if false must be false; if null don't care
* @param wantAvailable If true then inventory avilable must be true for the result to be true, if false must be false; if null don't care
*/
public static boolean isStoreInventoryRequiredAndAvailable(ServletRequest request, GenericValue product, BigDecimal quantity, Boolean
wantRequired, Boolean wantAvailable) {
GenericValue productStore = getProductStore(request);
if (productStore == null) {
Debug.logWarning("No ProductStore found, return false for inventory check", MODULE);
return false;
}
if (product == null) {
Debug.logWarning("No Product passed, return false for inventory check", MODULE);
return false;
}
if (quantity == null) quantity = BigDecimal.ONE;
String productStoreId = productStore.getString("productStoreId");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
try {
Boolean requiredOkay = null;
if (wantRequired != null) {
Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryRequired",
UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product,
"productStore", productStore));
if (ServiceUtil.isError(invReqResult)) {
Debug.logError("Error calling isStoreInventoryRequired service, result is: " + invReqResult, MODULE);
return false;
}
requiredOkay = wantRequired == "Y".equals(invReqResult.get("requireInventory"));
}
Boolean availableOkay = null;
if (wantAvailable != null) {
Map<String, Object> invAvailResult = dispatcher.runSync("isStoreInventoryAvailable",
UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product,
"productStore", productStore, "quantity", quantity));
if (ServiceUtil.isError(invAvailResult)) {
Debug.logError("Error calling isStoreInventoryAvailable service, result is: " + invAvailResult, MODULE);
return false;
}
availableOkay = wantAvailable == "Y".equals(invAvailResult.get("available"));
}
return (requiredOkay == null || requiredOkay) && (availableOkay == null || availableOkay);
} catch (GenericServiceException e) {
String errMsg = "Fatal error calling inventory checking services: " + e.toString();
Debug.logError(e, errMsg, MODULE);
return false;
}
}
public static boolean isStoreInventoryAvailable(ServletRequest request, ProductConfigWrapper productConfig, BigDecimal quantity) {
GenericValue productStore = getProductStore(request);
if (productStore == null) {
Debug.logWarning("No ProductStore found, return false for inventory check", MODULE);
return false;
}
String productStoreId = productStore.getString("productStoreId");
Delegator delegator = (Delegator) request.getAttribute("delegator");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
return isStoreInventoryAvailable(productStoreId, productConfig, quantity, delegator, dispatcher);
}
/** check inventory availability for the given catalog, product, quantity, etc */
public static boolean isStoreInventoryAvailable(String productStoreId, ProductConfigWrapper productConfig, BigDecimal quantity,
Delegator delegator, LocalDispatcher dispatcher) {
GenericValue productStore = getProductStore(productStoreId, delegator);
if (productStore == null) {
Debug.logWarning("No ProductStore found with id " + productStoreId + ", returning false for inventory available check", MODULE);
return false;
}
// if prodCatalog is set to not check inventory break here
if ("N".equals(productStore.getString("checkInventory"))) {
// note: if not set, defaults to yes, check inventory
if (Debug.verboseOn()) {
Debug.logVerbose("ProductStore with id " + productStoreId
+ ", is set to NOT check inventory, returning true for inventory available check", MODULE);
}
return true;
}
boolean isInventoryAvailable = false;
if ("Y".equals(productStore.getString("oneInventoryFacility"))) {
String inventoryFacilityId = productStore.getString("inventoryFacilityId");
if (UtilValidate.isEmpty(inventoryFacilityId)) {
Debug.logWarning("ProductStore with id " + productStoreId
+ " has Y for oneInventoryFacility but inventoryFacilityId is empty, returning false for inventory check", MODULE);
return false;
}
return ProductWorker.isProductInventoryAvailableByFacility(productConfig, inventoryFacilityId, quantity, dispatcher);
} else {
GenericValue product = productConfig.getProduct();
List<GenericValue> productFacilities = null;
try {
productFacilities = product.getRelated("ProductFacility", null, null, true);
} catch (GenericEntityException e) {
Debug.logWarning(e, "Error invoking getRelated in isCatalogInventoryAvailable", MODULE);
return false;
}
if (UtilValidate.isNotEmpty(productFacilities)) {
for (GenericValue pfValue: productFacilities) {
isInventoryAvailable = ProductWorker.isProductInventoryAvailableByFacility(productConfig,
pfValue.getString("facilityId"), quantity, dispatcher);
if (isInventoryAvailable) {
return isInventoryAvailable;
}
}
}
return false;
}
}
}
|
googleapis/google-cloud-java | 36,317 | java-tasks/proto-google-cloud-tasks-v2beta2/src/main/java/com/google/cloud/tasks/v2beta2/UpdateQueueRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/tasks/v2beta2/cloudtasks.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.tasks.v2beta2;
/**
*
*
* <pre>
* Request message for
* [UpdateQueue][google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue].
* </pre>
*
* Protobuf type {@code google.cloud.tasks.v2beta2.UpdateQueueRequest}
*/
public final class UpdateQueueRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.tasks.v2beta2.UpdateQueueRequest)
UpdateQueueRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateQueueRequest.newBuilder() to construct.
private UpdateQueueRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateQueueRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateQueueRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.tasks.v2beta2.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta2_UpdateQueueRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.tasks.v2beta2.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta2_UpdateQueueRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.tasks.v2beta2.UpdateQueueRequest.class,
com.google.cloud.tasks.v2beta2.UpdateQueueRequest.Builder.class);
}
private int bitField0_;
public static final int QUEUE_FIELD_NUMBER = 1;
private com.google.cloud.tasks.v2beta2.Queue queue_;
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the queue field is set.
*/
@java.lang.Override
public boolean hasQueue() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The queue.
*/
@java.lang.Override
public com.google.cloud.tasks.v2beta2.Queue getQueue() {
return queue_ == null ? com.google.cloud.tasks.v2beta2.Queue.getDefaultInstance() : queue_;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.tasks.v2beta2.QueueOrBuilder getQueueOrBuilder() {
return queue_ == null ? com.google.cloud.tasks.v2beta2.Queue.getDefaultInstance() : queue_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getQueue());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getQueue());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.tasks.v2beta2.UpdateQueueRequest)) {
return super.equals(obj);
}
com.google.cloud.tasks.v2beta2.UpdateQueueRequest other =
(com.google.cloud.tasks.v2beta2.UpdateQueueRequest) obj;
if (hasQueue() != other.hasQueue()) return false;
if (hasQueue()) {
if (!getQueue().equals(other.getQueue())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasQueue()) {
hash = (37 * hash) + QUEUE_FIELD_NUMBER;
hash = (53 * hash) + getQueue().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest 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.tasks.v2beta2.UpdateQueueRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest 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.tasks.v2beta2.UpdateQueueRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest 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.tasks.v2beta2.UpdateQueueRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest 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.tasks.v2beta2.UpdateQueueRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest 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.tasks.v2beta2.UpdateQueueRequest 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;
}
/**
*
*
* <pre>
* Request message for
* [UpdateQueue][google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue].
* </pre>
*
* Protobuf type {@code google.cloud.tasks.v2beta2.UpdateQueueRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.tasks.v2beta2.UpdateQueueRequest)
com.google.cloud.tasks.v2beta2.UpdateQueueRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.tasks.v2beta2.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta2_UpdateQueueRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.tasks.v2beta2.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta2_UpdateQueueRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.tasks.v2beta2.UpdateQueueRequest.class,
com.google.cloud.tasks.v2beta2.UpdateQueueRequest.Builder.class);
}
// Construct using com.google.cloud.tasks.v2beta2.UpdateQueueRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getQueueFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
queue_ = null;
if (queueBuilder_ != null) {
queueBuilder_.dispose();
queueBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.tasks.v2beta2.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta2_UpdateQueueRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.tasks.v2beta2.UpdateQueueRequest getDefaultInstanceForType() {
return com.google.cloud.tasks.v2beta2.UpdateQueueRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.tasks.v2beta2.UpdateQueueRequest build() {
com.google.cloud.tasks.v2beta2.UpdateQueueRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.tasks.v2beta2.UpdateQueueRequest buildPartial() {
com.google.cloud.tasks.v2beta2.UpdateQueueRequest result =
new com.google.cloud.tasks.v2beta2.UpdateQueueRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.tasks.v2beta2.UpdateQueueRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.queue_ = queueBuilder_ == null ? queue_ : queueBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.tasks.v2beta2.UpdateQueueRequest) {
return mergeFrom((com.google.cloud.tasks.v2beta2.UpdateQueueRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.tasks.v2beta2.UpdateQueueRequest other) {
if (other == com.google.cloud.tasks.v2beta2.UpdateQueueRequest.getDefaultInstance())
return this;
if (other.hasQueue()) {
mergeQueue(other.getQueue());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(getQueueFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.cloud.tasks.v2beta2.Queue queue_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.tasks.v2beta2.Queue,
com.google.cloud.tasks.v2beta2.Queue.Builder,
com.google.cloud.tasks.v2beta2.QueueOrBuilder>
queueBuilder_;
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the queue field is set.
*/
public boolean hasQueue() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The queue.
*/
public com.google.cloud.tasks.v2beta2.Queue getQueue() {
if (queueBuilder_ == null) {
return queue_ == null ? com.google.cloud.tasks.v2beta2.Queue.getDefaultInstance() : queue_;
} else {
return queueBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setQueue(com.google.cloud.tasks.v2beta2.Queue value) {
if (queueBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
queue_ = value;
} else {
queueBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setQueue(com.google.cloud.tasks.v2beta2.Queue.Builder builderForValue) {
if (queueBuilder_ == null) {
queue_ = builderForValue.build();
} else {
queueBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeQueue(com.google.cloud.tasks.v2beta2.Queue value) {
if (queueBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& queue_ != null
&& queue_ != com.google.cloud.tasks.v2beta2.Queue.getDefaultInstance()) {
getQueueBuilder().mergeFrom(value);
} else {
queue_ = value;
}
} else {
queueBuilder_.mergeFrom(value);
}
if (queue_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearQueue() {
bitField0_ = (bitField0_ & ~0x00000001);
queue_ = null;
if (queueBuilder_ != null) {
queueBuilder_.dispose();
queueBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.tasks.v2beta2.Queue.Builder getQueueBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getQueueFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.tasks.v2beta2.QueueOrBuilder getQueueOrBuilder() {
if (queueBuilder_ != null) {
return queueBuilder_.getMessageOrBuilder();
} else {
return queue_ == null ? com.google.cloud.tasks.v2beta2.Queue.getDefaultInstance() : queue_;
}
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta2.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta2.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.tasks.v2beta2.Queue,
com.google.cloud.tasks.v2beta2.Queue.Builder,
com.google.cloud.tasks.v2beta2.QueueOrBuilder>
getQueueFieldBuilder() {
if (queueBuilder_ == null) {
queueBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.tasks.v2beta2.Queue,
com.google.cloud.tasks.v2beta2.Queue.Builder,
com.google.cloud.tasks.v2beta2.QueueOrBuilder>(
getQueue(), getParentForChildren(), isClean());
queue_ = null;
}
return queueBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.tasks.v2beta2.UpdateQueueRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.tasks.v2beta2.UpdateQueueRequest)
private static final com.google.cloud.tasks.v2beta2.UpdateQueueRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.tasks.v2beta2.UpdateQueueRequest();
}
public static com.google.cloud.tasks.v2beta2.UpdateQueueRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateQueueRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateQueueRequest>() {
@java.lang.Override
public UpdateQueueRequest 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<UpdateQueueRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateQueueRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.tasks.v2beta2.UpdateQueueRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,317 | java-tasks/proto-google-cloud-tasks-v2beta3/src/main/java/com/google/cloud/tasks/v2beta3/UpdateQueueRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/tasks/v2beta3/cloudtasks.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.tasks.v2beta3;
/**
*
*
* <pre>
* Request message for
* [UpdateQueue][google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue].
* </pre>
*
* Protobuf type {@code google.cloud.tasks.v2beta3.UpdateQueueRequest}
*/
public final class UpdateQueueRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.tasks.v2beta3.UpdateQueueRequest)
UpdateQueueRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateQueueRequest.newBuilder() to construct.
private UpdateQueueRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateQueueRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateQueueRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.tasks.v2beta3.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta3_UpdateQueueRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.tasks.v2beta3.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta3_UpdateQueueRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.tasks.v2beta3.UpdateQueueRequest.class,
com.google.cloud.tasks.v2beta3.UpdateQueueRequest.Builder.class);
}
private int bitField0_;
public static final int QUEUE_FIELD_NUMBER = 1;
private com.google.cloud.tasks.v2beta3.Queue queue_;
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the queue field is set.
*/
@java.lang.Override
public boolean hasQueue() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The queue.
*/
@java.lang.Override
public com.google.cloud.tasks.v2beta3.Queue getQueue() {
return queue_ == null ? com.google.cloud.tasks.v2beta3.Queue.getDefaultInstance() : queue_;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.tasks.v2beta3.QueueOrBuilder getQueueOrBuilder() {
return queue_ == null ? com.google.cloud.tasks.v2beta3.Queue.getDefaultInstance() : queue_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getQueue());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getQueue());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.tasks.v2beta3.UpdateQueueRequest)) {
return super.equals(obj);
}
com.google.cloud.tasks.v2beta3.UpdateQueueRequest other =
(com.google.cloud.tasks.v2beta3.UpdateQueueRequest) obj;
if (hasQueue() != other.hasQueue()) return false;
if (hasQueue()) {
if (!getQueue().equals(other.getQueue())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasQueue()) {
hash = (37 * hash) + QUEUE_FIELD_NUMBER;
hash = (53 * hash) + getQueue().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest 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.tasks.v2beta3.UpdateQueueRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest 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.tasks.v2beta3.UpdateQueueRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest 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.tasks.v2beta3.UpdateQueueRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest 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.tasks.v2beta3.UpdateQueueRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest 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.tasks.v2beta3.UpdateQueueRequest 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;
}
/**
*
*
* <pre>
* Request message for
* [UpdateQueue][google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue].
* </pre>
*
* Protobuf type {@code google.cloud.tasks.v2beta3.UpdateQueueRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.tasks.v2beta3.UpdateQueueRequest)
com.google.cloud.tasks.v2beta3.UpdateQueueRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.tasks.v2beta3.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta3_UpdateQueueRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.tasks.v2beta3.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta3_UpdateQueueRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.tasks.v2beta3.UpdateQueueRequest.class,
com.google.cloud.tasks.v2beta3.UpdateQueueRequest.Builder.class);
}
// Construct using com.google.cloud.tasks.v2beta3.UpdateQueueRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getQueueFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
queue_ = null;
if (queueBuilder_ != null) {
queueBuilder_.dispose();
queueBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.tasks.v2beta3.CloudTasksProto
.internal_static_google_cloud_tasks_v2beta3_UpdateQueueRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.tasks.v2beta3.UpdateQueueRequest getDefaultInstanceForType() {
return com.google.cloud.tasks.v2beta3.UpdateQueueRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.tasks.v2beta3.UpdateQueueRequest build() {
com.google.cloud.tasks.v2beta3.UpdateQueueRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.tasks.v2beta3.UpdateQueueRequest buildPartial() {
com.google.cloud.tasks.v2beta3.UpdateQueueRequest result =
new com.google.cloud.tasks.v2beta3.UpdateQueueRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.tasks.v2beta3.UpdateQueueRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.queue_ = queueBuilder_ == null ? queue_ : queueBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.tasks.v2beta3.UpdateQueueRequest) {
return mergeFrom((com.google.cloud.tasks.v2beta3.UpdateQueueRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.tasks.v2beta3.UpdateQueueRequest other) {
if (other == com.google.cloud.tasks.v2beta3.UpdateQueueRequest.getDefaultInstance())
return this;
if (other.hasQueue()) {
mergeQueue(other.getQueue());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(getQueueFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.cloud.tasks.v2beta3.Queue queue_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.tasks.v2beta3.Queue,
com.google.cloud.tasks.v2beta3.Queue.Builder,
com.google.cloud.tasks.v2beta3.QueueOrBuilder>
queueBuilder_;
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the queue field is set.
*/
public boolean hasQueue() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The queue.
*/
public com.google.cloud.tasks.v2beta3.Queue getQueue() {
if (queueBuilder_ == null) {
return queue_ == null ? com.google.cloud.tasks.v2beta3.Queue.getDefaultInstance() : queue_;
} else {
return queueBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setQueue(com.google.cloud.tasks.v2beta3.Queue value) {
if (queueBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
queue_ = value;
} else {
queueBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setQueue(com.google.cloud.tasks.v2beta3.Queue.Builder builderForValue) {
if (queueBuilder_ == null) {
queue_ = builderForValue.build();
} else {
queueBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeQueue(com.google.cloud.tasks.v2beta3.Queue value) {
if (queueBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& queue_ != null
&& queue_ != com.google.cloud.tasks.v2beta3.Queue.getDefaultInstance()) {
getQueueBuilder().mergeFrom(value);
} else {
queue_ = value;
}
} else {
queueBuilder_.mergeFrom(value);
}
if (queue_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearQueue() {
bitField0_ = (bitField0_ & ~0x00000001);
queue_ = null;
if (queueBuilder_ != null) {
queueBuilder_.dispose();
queueBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.tasks.v2beta3.Queue.Builder getQueueBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getQueueFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.tasks.v2beta3.QueueOrBuilder getQueueOrBuilder() {
if (queueBuilder_ != null) {
return queueBuilder_.getMessageOrBuilder();
} else {
return queue_ == null ? com.google.cloud.tasks.v2beta3.Queue.getDefaultInstance() : queue_;
}
}
/**
*
*
* <pre>
* Required. The queue to create or update.
*
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] must be
* specified.
*
* Output only fields cannot be modified using UpdateQueue.
* Any value specified for an output only field will be ignored.
* The queue's [name][google.cloud.tasks.v2beta3.Queue.name] cannot be
* changed.
* </pre>
*
* <code>.google.cloud.tasks.v2beta3.Queue queue = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.tasks.v2beta3.Queue,
com.google.cloud.tasks.v2beta3.Queue.Builder,
com.google.cloud.tasks.v2beta3.QueueOrBuilder>
getQueueFieldBuilder() {
if (queueBuilder_ == null) {
queueBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.tasks.v2beta3.Queue,
com.google.cloud.tasks.v2beta3.Queue.Builder,
com.google.cloud.tasks.v2beta3.QueueOrBuilder>(
getQueue(), getParentForChildren(), isClean());
queue_ = null;
}
return queueBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* A mask used to specify which fields of the queue are being updated.
*
* If empty, then all fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.tasks.v2beta3.UpdateQueueRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.tasks.v2beta3.UpdateQueueRequest)
private static final com.google.cloud.tasks.v2beta3.UpdateQueueRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.tasks.v2beta3.UpdateQueueRequest();
}
public static com.google.cloud.tasks.v2beta3.UpdateQueueRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateQueueRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateQueueRequest>() {
@java.lang.Override
public UpdateQueueRequest 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<UpdateQueueRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateQueueRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.tasks.v2beta3.UpdateQueueRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,366 | java-gke-multi-cloud/proto-google-cloud-gke-multi-cloud-v1/src/main/java/com/google/cloud/gkemulticloud/v1/MonitoringConfig.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/gkemulticloud/v1/common_resources.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.gkemulticloud.v1;
/**
*
*
* <pre>
* Parameters that describe the Monitoring configuration in a cluster.
* </pre>
*
* Protobuf type {@code google.cloud.gkemulticloud.v1.MonitoringConfig}
*/
public final class MonitoringConfig extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.gkemulticloud.v1.MonitoringConfig)
MonitoringConfigOrBuilder {
private static final long serialVersionUID = 0L;
// Use MonitoringConfig.newBuilder() to construct.
private MonitoringConfig(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private MonitoringConfig() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new MonitoringConfig();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.gkemulticloud.v1.CommonResourcesProto
.internal_static_google_cloud_gkemulticloud_v1_MonitoringConfig_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.gkemulticloud.v1.CommonResourcesProto
.internal_static_google_cloud_gkemulticloud_v1_MonitoringConfig_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.gkemulticloud.v1.MonitoringConfig.class,
com.google.cloud.gkemulticloud.v1.MonitoringConfig.Builder.class);
}
private int bitField0_;
public static final int MANAGED_PROMETHEUS_CONFIG_FIELD_NUMBER = 2;
private com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managedPrometheusConfig_;
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*
* @return Whether the managedPrometheusConfig field is set.
*/
@java.lang.Override
public boolean hasManagedPrometheusConfig() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*
* @return The managedPrometheusConfig.
*/
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig getManagedPrometheusConfig() {
return managedPrometheusConfig_ == null
? com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.getDefaultInstance()
: managedPrometheusConfig_;
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfigOrBuilder
getManagedPrometheusConfigOrBuilder() {
return managedPrometheusConfig_ == null
? com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.getDefaultInstance()
: managedPrometheusConfig_;
}
public static final int CLOUD_MONITORING_CONFIG_FIELD_NUMBER = 4;
private com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloudMonitoringConfig_;
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;</code>
*
* @return Whether the cloudMonitoringConfig field is set.
*/
@java.lang.Override
public boolean hasCloudMonitoringConfig() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;</code>
*
* @return The cloudMonitoringConfig.
*/
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig getCloudMonitoringConfig() {
return cloudMonitoringConfig_ == null
? com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.getDefaultInstance()
: cloudMonitoringConfig_;
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;</code>
*/
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.CloudMonitoringConfigOrBuilder
getCloudMonitoringConfigOrBuilder() {
return cloudMonitoringConfig_ == null
? com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.getDefaultInstance()
: cloudMonitoringConfig_;
}
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)) {
output.writeMessage(2, getManagedPrometheusConfig());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(4, getCloudMonitoringConfig());
}
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.CodedOutputStream.computeMessageSize(2, getManagedPrometheusConfig());
}
if (((bitField0_ & 0x00000002) != 0)) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(4, getCloudMonitoringConfig());
}
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.gkemulticloud.v1.MonitoringConfig)) {
return super.equals(obj);
}
com.google.cloud.gkemulticloud.v1.MonitoringConfig other =
(com.google.cloud.gkemulticloud.v1.MonitoringConfig) obj;
if (hasManagedPrometheusConfig() != other.hasManagedPrometheusConfig()) return false;
if (hasManagedPrometheusConfig()) {
if (!getManagedPrometheusConfig().equals(other.getManagedPrometheusConfig())) return false;
}
if (hasCloudMonitoringConfig() != other.hasCloudMonitoringConfig()) return false;
if (hasCloudMonitoringConfig()) {
if (!getCloudMonitoringConfig().equals(other.getCloudMonitoringConfig())) 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 (hasManagedPrometheusConfig()) {
hash = (37 * hash) + MANAGED_PROMETHEUS_CONFIG_FIELD_NUMBER;
hash = (53 * hash) + getManagedPrometheusConfig().hashCode();
}
if (hasCloudMonitoringConfig()) {
hash = (37 * hash) + CLOUD_MONITORING_CONFIG_FIELD_NUMBER;
hash = (53 * hash) + getCloudMonitoringConfig().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig 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.gkemulticloud.v1.MonitoringConfig parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig 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.gkemulticloud.v1.MonitoringConfig parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig 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.gkemulticloud.v1.MonitoringConfig parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig 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.gkemulticloud.v1.MonitoringConfig parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig 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.gkemulticloud.v1.MonitoringConfig 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;
}
/**
*
*
* <pre>
* Parameters that describe the Monitoring configuration in a cluster.
* </pre>
*
* Protobuf type {@code google.cloud.gkemulticloud.v1.MonitoringConfig}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.gkemulticloud.v1.MonitoringConfig)
com.google.cloud.gkemulticloud.v1.MonitoringConfigOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.gkemulticloud.v1.CommonResourcesProto
.internal_static_google_cloud_gkemulticloud_v1_MonitoringConfig_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.gkemulticloud.v1.CommonResourcesProto
.internal_static_google_cloud_gkemulticloud_v1_MonitoringConfig_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.gkemulticloud.v1.MonitoringConfig.class,
com.google.cloud.gkemulticloud.v1.MonitoringConfig.Builder.class);
}
// Construct using com.google.cloud.gkemulticloud.v1.MonitoringConfig.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getManagedPrometheusConfigFieldBuilder();
getCloudMonitoringConfigFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
managedPrometheusConfig_ = null;
if (managedPrometheusConfigBuilder_ != null) {
managedPrometheusConfigBuilder_.dispose();
managedPrometheusConfigBuilder_ = null;
}
cloudMonitoringConfig_ = null;
if (cloudMonitoringConfigBuilder_ != null) {
cloudMonitoringConfigBuilder_.dispose();
cloudMonitoringConfigBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.gkemulticloud.v1.CommonResourcesProto
.internal_static_google_cloud_gkemulticloud_v1_MonitoringConfig_descriptor;
}
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.MonitoringConfig getDefaultInstanceForType() {
return com.google.cloud.gkemulticloud.v1.MonitoringConfig.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.MonitoringConfig build() {
com.google.cloud.gkemulticloud.v1.MonitoringConfig result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.MonitoringConfig buildPartial() {
com.google.cloud.gkemulticloud.v1.MonitoringConfig result =
new com.google.cloud.gkemulticloud.v1.MonitoringConfig(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.gkemulticloud.v1.MonitoringConfig result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.managedPrometheusConfig_ =
managedPrometheusConfigBuilder_ == null
? managedPrometheusConfig_
: managedPrometheusConfigBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.cloudMonitoringConfig_ =
cloudMonitoringConfigBuilder_ == null
? cloudMonitoringConfig_
: cloudMonitoringConfigBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.gkemulticloud.v1.MonitoringConfig) {
return mergeFrom((com.google.cloud.gkemulticloud.v1.MonitoringConfig) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.gkemulticloud.v1.MonitoringConfig other) {
if (other == com.google.cloud.gkemulticloud.v1.MonitoringConfig.getDefaultInstance())
return this;
if (other.hasManagedPrometheusConfig()) {
mergeManagedPrometheusConfig(other.getManagedPrometheusConfig());
}
if (other.hasCloudMonitoringConfig()) {
mergeCloudMonitoringConfig(other.getCloudMonitoringConfig());
}
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 18:
{
input.readMessage(
getManagedPrometheusConfigFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 18
case 34:
{
input.readMessage(
getCloudMonitoringConfigFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 34
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 com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managedPrometheusConfig_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig,
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.Builder,
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfigOrBuilder>
managedPrometheusConfigBuilder_;
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*
* @return Whether the managedPrometheusConfig field is set.
*/
public boolean hasManagedPrometheusConfig() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*
* @return The managedPrometheusConfig.
*/
public com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig getManagedPrometheusConfig() {
if (managedPrometheusConfigBuilder_ == null) {
return managedPrometheusConfig_ == null
? com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.getDefaultInstance()
: managedPrometheusConfig_;
} else {
return managedPrometheusConfigBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
public Builder setManagedPrometheusConfig(
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig value) {
if (managedPrometheusConfigBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
managedPrometheusConfig_ = value;
} else {
managedPrometheusConfigBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
public Builder setManagedPrometheusConfig(
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.Builder builderForValue) {
if (managedPrometheusConfigBuilder_ == null) {
managedPrometheusConfig_ = builderForValue.build();
} else {
managedPrometheusConfigBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
public Builder mergeManagedPrometheusConfig(
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig value) {
if (managedPrometheusConfigBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& managedPrometheusConfig_ != null
&& managedPrometheusConfig_
!= com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.getDefaultInstance()) {
getManagedPrometheusConfigBuilder().mergeFrom(value);
} else {
managedPrometheusConfig_ = value;
}
} else {
managedPrometheusConfigBuilder_.mergeFrom(value);
}
if (managedPrometheusConfig_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
public Builder clearManagedPrometheusConfig() {
bitField0_ = (bitField0_ & ~0x00000001);
managedPrometheusConfig_ = null;
if (managedPrometheusConfigBuilder_ != null) {
managedPrometheusConfigBuilder_.dispose();
managedPrometheusConfigBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
public com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.Builder
getManagedPrometheusConfigBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getManagedPrometheusConfigFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
public com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfigOrBuilder
getManagedPrometheusConfigOrBuilder() {
if (managedPrometheusConfigBuilder_ != null) {
return managedPrometheusConfigBuilder_.getMessageOrBuilder();
} else {
return managedPrometheusConfig_ == null
? com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.getDefaultInstance()
: managedPrometheusConfig_;
}
}
/**
*
*
* <pre>
* Enable Google Cloud Managed Service for Prometheus in the cluster.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig managed_prometheus_config = 2;
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig,
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.Builder,
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfigOrBuilder>
getManagedPrometheusConfigFieldBuilder() {
if (managedPrometheusConfigBuilder_ == null) {
managedPrometheusConfigBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig,
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfig.Builder,
com.google.cloud.gkemulticloud.v1.ManagedPrometheusConfigOrBuilder>(
getManagedPrometheusConfig(), getParentForChildren(), isClean());
managedPrometheusConfig_ = null;
}
return managedPrometheusConfigBuilder_;
}
private com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloudMonitoringConfig_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig,
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.Builder,
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfigOrBuilder>
cloudMonitoringConfigBuilder_;
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*
* @return Whether the cloudMonitoringConfig field is set.
*/
public boolean hasCloudMonitoringConfig() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*
* @return The cloudMonitoringConfig.
*/
public com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig getCloudMonitoringConfig() {
if (cloudMonitoringConfigBuilder_ == null) {
return cloudMonitoringConfig_ == null
? com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.getDefaultInstance()
: cloudMonitoringConfig_;
} else {
return cloudMonitoringConfigBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*/
public Builder setCloudMonitoringConfig(
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig value) {
if (cloudMonitoringConfigBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
cloudMonitoringConfig_ = value;
} else {
cloudMonitoringConfigBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*/
public Builder setCloudMonitoringConfig(
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.Builder builderForValue) {
if (cloudMonitoringConfigBuilder_ == null) {
cloudMonitoringConfig_ = builderForValue.build();
} else {
cloudMonitoringConfigBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*/
public Builder mergeCloudMonitoringConfig(
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig value) {
if (cloudMonitoringConfigBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& cloudMonitoringConfig_ != null
&& cloudMonitoringConfig_
!= com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.getDefaultInstance()) {
getCloudMonitoringConfigBuilder().mergeFrom(value);
} else {
cloudMonitoringConfig_ = value;
}
} else {
cloudMonitoringConfigBuilder_.mergeFrom(value);
}
if (cloudMonitoringConfig_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*/
public Builder clearCloudMonitoringConfig() {
bitField0_ = (bitField0_ & ~0x00000002);
cloudMonitoringConfig_ = null;
if (cloudMonitoringConfigBuilder_ != null) {
cloudMonitoringConfigBuilder_.dispose();
cloudMonitoringConfigBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*/
public com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.Builder
getCloudMonitoringConfigBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getCloudMonitoringConfigFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*/
public com.google.cloud.gkemulticloud.v1.CloudMonitoringConfigOrBuilder
getCloudMonitoringConfigOrBuilder() {
if (cloudMonitoringConfigBuilder_ != null) {
return cloudMonitoringConfigBuilder_.getMessageOrBuilder();
} else {
return cloudMonitoringConfig_ == null
? com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.getDefaultInstance()
: cloudMonitoringConfig_;
}
}
/**
*
*
* <pre>
* Optionally enable GKE metrics.
* Only for Attached Clusters.
* </pre>
*
* <code>.google.cloud.gkemulticloud.v1.CloudMonitoringConfig cloud_monitoring_config = 4;
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig,
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.Builder,
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfigOrBuilder>
getCloudMonitoringConfigFieldBuilder() {
if (cloudMonitoringConfigBuilder_ == null) {
cloudMonitoringConfigBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig,
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfig.Builder,
com.google.cloud.gkemulticloud.v1.CloudMonitoringConfigOrBuilder>(
getCloudMonitoringConfig(), getParentForChildren(), isClean());
cloudMonitoringConfig_ = null;
}
return cloudMonitoringConfigBuilder_;
}
@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.gkemulticloud.v1.MonitoringConfig)
}
// @@protoc_insertion_point(class_scope:google.cloud.gkemulticloud.v1.MonitoringConfig)
private static final com.google.cloud.gkemulticloud.v1.MonitoringConfig DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.gkemulticloud.v1.MonitoringConfig();
}
public static com.google.cloud.gkemulticloud.v1.MonitoringConfig getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<MonitoringConfig> PARSER =
new com.google.protobuf.AbstractParser<MonitoringConfig>() {
@java.lang.Override
public MonitoringConfig 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<MonitoringConfig> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<MonitoringConfig> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.gkemulticloud.v1.MonitoringConfig getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/incubator-brooklyn | 36,122 | brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/ssh/BashCommands.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.brooklyn.util.ssh;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.text.Identifiers;
import org.apache.brooklyn.util.text.Strings;
import org.apache.brooklyn.util.text.StringEscapes.BashStringEscapes;
import org.apache.brooklyn.util.time.Duration;
import com.google.common.annotations.Beta;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
public class BashCommands {
/**
* Returns a string for checking whether the given executable is available,
* and installing it if necessary.
* <p/>
* Uses {@link #installPackage} and accepts the same flags e.g. for apt, yum, rpm.
*/
public static String installExecutable(Map<?,?> flags, String executable) {
return onlyIfExecutableMissing(executable, installPackage(flags, executable));
}
public static String installExecutable(String executable) {
return installExecutable(MutableMap.of(), executable);
}
/**
* Returns a command with all output redirected to /dev/null
*/
public static String quiet(String command) {
return format("(%s > /dev/null 2>&1)", command);
}
/**
* Returns a command that always exits successfully
*/
public static String ok(String command) {
return String.format("(%s || true)", command);
}
/**
* Returns a command for safely running as root, using {@code sudo}.
* <p/>
* Ensuring non-blocking if password not set by using
* {@code -n} which means to exit if password required
* (this is unsupported in Ubuntu 8 but all modern OS's seem okay with this!),
* and (perhaps unnecessarily ?)
* {@code -S} which reads from stdin (routed to {@code /dev/null}, it was claimed here previously, though I'm not sure?).
* <p/>
* Also specify {@code -E} to pass the parent environment in.
* <p/>
* If already root, simply runs the command, wrapped in brackets in case it is backgrounded.
* <p/>
* The command is not quoted or escaped in any ways.
* If you are doing privileged redirect you may need to pass e.g. "bash -c 'echo hi > file'".
* <p/>
* If null is supplied, it is returned (sometimes used to indicate no command desired).
*/
public static String sudo(String command) {
if (command.startsWith("( ") || command.endsWith(" &"))
return sudoNew(command);
else
return sudoOld(command);
}
// TODO would like to move away from sudoOld -- but needs extensive testing!
private static String sudoOld(String command) {
if (command==null) return null;
// some OS's (which?) fail if you try running sudo when you're already root (dumb but true)
return format("( if test \"$UID\" -eq 0; then ( %s ); else sudo -E -n -S -- %s; fi )", command, command);
}
private static String sudoNew(String command) {
if (command==null) return null;
// on some OS's e.g. Centos 6.5 in SL, sudo -- X tries to run X as a literal argument;
// in particular "( echo foo && echo bar )" fails when passed as an argument in that way,
// but works if passed to bash -c;
// but others e.g. OS X fail if you say sudo -- bash -c "( echo foo )" ... not liking the parentheses
// piping to sudo bash seems the most reliable way
return "( if test \"$UID\" -eq 0; then ( "+command+" ); else "
+ "echo " + BashStringEscapes.wrapBash(command) + " | "
+ "sudo -E -n -S -s -- bash"
+ " ; fi )";
}
/** sudo to a given user and run the indicated command;
* @deprecated since 0.7.0 semantics of this are fiddly, e.g. whether user gets their environment */
@Beta
public static String sudoAsUser(String user, String command) {
return sudoAsUserOld(user, command);
}
private static String sudoAsUserOld(String user, String command) {
if (command == null) return null;
return format("{ sudo -E -n -u %s -s -- %s ; }", user, command);
}
// TODO would like to move away from sudoOld -- but needs extensive testing!
// private static String sudoAsUserNew(String user, String command) {
// if (command == null) return null;
// // no -E, run with permissions of this user
// // FIXME still doesn't always work e.g. doesn't have path of user
// // (Alex says: can't find any combinations which work reliably)
// return "{ sudo -n -S -i -u "+user+" -- "+BashStringEscapes.wrapBash(command)+" ; }";
// }
public static String addSbinPathCommand() {
return "export PATH=" + sbinPath();
}
public static String sbinPath() {
return "$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
}
/** executes a command, then as user tees the output to the given file.
* useful e.g. for appending to a file which is only writable by root or a priveleged user. */
public static String executeCommandThenAsUserTeeOutputToFile(String commandWhoseOutputToWrite, String user, String file) {
return format("{ %s | sudo -E -n -u %s -s -- tee -a %s ; }",
commandWhoseOutputToWrite, user, file);
}
/** some machines require a tty for sudo; brooklyn by default does not use a tty
* (so that it can get separate error+stdout streams); you can enable a tty as an
* option to every ssh command, or you can do it once and
* modify the machine so that a tty is not subsequently required.
* <p>
* this command must be run with allocatePTY set as a flag to ssh. see SshTasks.dontRequireTtyForSudo which sets that up.
* <p>
* (having a tty for sudo seems like another case of imaginary security which is just irritating.
* like water restrictions at airport security.) */
public static String dontRequireTtyForSudo() {
String sudoersFileName = "/etc/sudoers";
// Visudo's quiet mode (-q) is not enabled. visudo's output is used for diagnostic purposes
return ifFileExistsElse0(sudoersFileName,
chainGroup(
sudo(format("cp %1$s %1$s.tmp", sudoersFileName)),
sudo(format("sed -i.brooklyn.bak 's/.*requiretty.*/#brooklyn-removed-require-tty/' %1$s.tmp", sudoersFileName)),
sudo(format("visudo -c -f %1$s.tmp", sudoersFileName)),
sudo(format("mv %1$s.tmp %1$s", sudoersFileName))));
}
/** generates ~/.ssh/id_rsa if that file does not exist */
public static String generateKeyInDotSshIdRsaIfNotThere() {
return "[ -f ~/.ssh/id_rsa ] || ( mkdir -p ~/.ssh ; chmod 700 ~/.ssh ; ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa )";
}
// TODO a builder would be better than these ifBlahExistsElseBlah methods!
// (ideally formatting better also; though maybe SshTasks would be better?)
/**
* Returns a command that runs only if the specified file (or link or directory) exists;
* if the command runs and fails that exit is preserved (but if the file does not exist exit code is zero).
* Executed as { { not-file-exists && ok ; } || command ; } for portability.
* ("if [ ... ] ; then xxx ; else xxx ; fi" syntax is not quite as portable, I seem to recall (not sure, Alex Aug 2013).)
*/
public static String ifFileExistsElse0(String path, String command) {
return alternativesGroup(
chainGroup(format("test ! -e %s", path), "true"),
command);
}
/** as {@link #ifFileExistsElse0(String, String)} but returns non-zero if the test fails (also returns non-zero if the command fails,
* so you can't tell the difference :( -- we need if ; then ; else ; fi semantics for that I think, but not sure how portable that is) */
public static String ifFileExistsElse1(String path, String command) {
return chainGroup(format("test -e %s", path), command);
}
/**
* Returns a command that runs only if the specified executable exists on the path (using `which`).
* if the command runs and fails that exit is preserved (but if the executable is not on the path exit code is zero).
* @see #ifFileExistsElse0(String, String) for implementation discussion, using <code>{ { test -z `which executable` && true ; } || command ; }
*/
public static String ifExecutableElse0(String executable, String command) {
return alternativesGroup(
chainGroup(format("test -z `which %s`", executable), "true"),
command);
}
/** as {@link #ifExecutableElse0(String, String)} but returns 1 if the test fails (also returns non-zero if the command fails) */
public static String ifExecutableElse1(String executable, String command) {
return chainGroup(format("which %s", executable), command);
}
/**
* Returns a command which
* executes <code>statement</code> only if <code>command</code> is NOT found in <code>$PATH</code>
*
* @param command
* @param statement
* @return command
*/
public static String ifNotExecutable(String command, String statement) {
return String.format("{ { test ! -z `which %s`; } || { %s; } }", command, statement);
}
/**
* Returns a command that runs only if the specified executable exists on the path (using `which`).
* if the command runs and fails that exit is preserved (but if the executable is not on the path exit code is zero).
* @see #ifFileExistsElse0(String, String) for implementation discussion, using <code>{ { test -z `which executable` && true ; } || command ; }
*/
public static String onlyIfExecutableMissing(String executable, String command) {
return alternativesGroup(format("which %s", executable), command);
}
public static String ifExecutableElse(String command, String ifTrue, String otherwise) {
return com.google.common.base.Joiner.on('\n').join(
ifExecutableElse(command, ImmutableList.<String>of(ifTrue), ImmutableList.<String>of(otherwise)));
}
public static ImmutableList<String> ifExecutableElse(String command, List<String> ifTrue, List<String> otherwise) {
return ImmutableList.<String>builder()
.add(String.format("if test -z `which %s`; then", command))
.addAll(ifTrue)
.add("else")
.addAll(otherwise)
.add("fi")
.build();
}
/**
* Returns a sequence of chained commands that runs until one of them fails (i.e. joined by '&&')
* This currently runs as a subshell (so exits are swallowed) but behaviour may be changed imminently.
* (Use {@link #chainGroup(Collection)} or {@link #chainSubshell(Collection)} to be clear.)
*/
public static String chain(Collection<String> commands) {
return "( " + Strings.join(commands, " && ") + " )";
}
/** Convenience for {@link #chain(Collection)} */
public static String chain(String ...commands) {
return "( " + Strings.join(commands, " && ") + " )";
}
/** As {@link #chain(Collection)}, but explicitly using { } grouping characters
* to ensure exits are propagated. */
public static String chainGroup(Collection<String> commands) {
// spaces required around curly braces
return "{ " + Strings.join(commands, " && ") + " ; }";
}
/** As {@link #chainGroup(Collection)} */
public static String chainGroup(String ...commands) {
return "{ " + Strings.join(commands, " && ") + " ; }";
}
/** As {@link #chain(Collection)}, but explicitly using ( ) grouping characters
* to ensure exits are caught. */
public static String chainSubshell(Collection<String> commands) {
// the spaces are not required, but it might be possible that a (( expr )) is interpreted differently
// (won't hurt to have the spaces in any case!)
return "( " + Strings.join(commands, " && ") + " )";
}
/** As {@link #chainSubshell(Collection)} */
public static String chainSubshell(String ...commands) {
return "( " + Strings.join(commands, " && ") + " )";
}
/**
* Returns a sequence of chained commands that runs until one of them succeeds (i.e. joined by '||').
* This currently runs as a subshell (so exits are swallowed) but behaviour may be changed imminently.
* (Use {@link #alternativesGroup(Collection)} or {@link #alternativesSubshell(Collection)} to be clear.)
*/
public static String alternatives(Collection<String> commands) {
return "( " + Strings.join(commands, " || ") + " )";
}
/** As {@link #alternatives(Collection)} */
public static String alternatives(String ...commands) {
return "( " + Strings.join(commands, " || ") + " )";
}
/** As {@link #alternatives(Collection)}, but explicitly using { } grouping characters
* to ensure exits are propagated. */
public static String alternativesGroup(Collection<String> commands) {
// spaces required around curly braces
return "{ " + Strings.join(commands, " || ") + " ; }";
}
/** As {@link #alternativesGroup(Collection)} */
public static String alternativesGroup(String ...commands) {
return "{ " + Strings.join(commands, " || ") + " ; }";
}
/** As {@link #alternatives(Collection)}, but explicitly using ( ) grouping characters
* to ensure exits are caught. */
public static String alternativesSubshell(Collection<String> commands) {
// the spaces are not required, but it might be possible that a (( expr )) is interpreted differently
// (won't hurt to have the spaces in any case!)
return "( " + Strings.join(commands, " || ") + " )";
}
/** As {@link #alternativesSubshell(Collection)} */
public static String alternativesSubshell(String ...commands) {
return "( " + Strings.join(commands, " || ") + " )";
}
/** returns the pattern formatted with the given arg if the arg is not null, otherwise returns null */
public static String formatIfNotNull(String pattern, Object arg) {
if (arg==null) return null;
return format(pattern, arg);
}
public static String installPackage(String packageDefaultName) {
return installPackage(MutableMap.of(), packageDefaultName);
}
/**
* Returns a command for installing the given package.
* <p>
* Warns, but does not fail or return non-zero if it ultimately fails.
* <p>
* Flags can contain common overrides for {@code apt}, {@code yum}, {@code port} and {@code brew}
* as the package names can be different for each of those. Setting the default package name to
* {@literal null} will use only the overridden package manager values. The {@code onlyifmissing} flag
* adds a check for an executable, and only attempts to install packages if it is not found.
* <pre>
* installPackage(ImmutableMap.of("yum", "openssl-devel", "apt", "openssl libssl-dev zlib1g-dev"), "libssl-devel");
* installPackage(ImmutableMap.of("apt", "libaio1"), null);
* installPackage(ImmutableMap.of("onlyifmissing", "curl"), "curl");
* </pre>
*/
public static String installPackage(Map<?,?> flags, String packageDefaultName) {
return installPackageOr(flags, packageDefaultName, null);
}
public static String installPackageOrFail(Map<?,?> flags, String packageDefaultName) {
return installPackageOr(flags, packageDefaultName, "exit 9");
}
public static String installPackageOr(Map<?,?> flags, String packageDefaultName, String optionalCommandToRunIfNone) {
String ifMissing = (String) flags.get("onlyifmissing");
String zypperInstall = formatIfNotNull("zypper --non-interactive --no-gpg-checks install %s", getFlag(flags, "zypper", packageDefaultName));
String aptInstall = formatIfNotNull("apt-get install -y --allow-unauthenticated %s", getFlag(flags, "apt", packageDefaultName));
String yumInstall = formatIfNotNull("yum -y --nogpgcheck install %s", getFlag(flags, "yum", packageDefaultName));
String brewInstall = formatIfNotNull("brew install %s", getFlag(flags, "brew", packageDefaultName));
String portInstall = formatIfNotNull("port install %s", getFlag(flags, "port", packageDefaultName));
List<String> commands = new LinkedList<String>();
if (ifMissing != null)
commands.add(format("which %s", ifMissing));
if (zypperInstall != null)
commands.add(ifExecutableElse1("zypper",
chainGroup(
"echo zypper exists, doing refresh",
ok(sudo("zypper --non-interactive --no-gpg-checks refresh")),
sudo(zypperInstall))));
if (aptInstall != null)
commands.add(ifExecutableElse1("apt-get",
chainGroup(
"echo apt-get exists, doing update",
"export DEBIAN_FRONTEND=noninteractive",
ok(sudo("apt-get update")),
sudo(aptInstall))));
if (yumInstall != null)
// Need to upgrade ca-certificates sometimes:
// http://serverfault.com/questions/637549/epel-repo-for-centos-6-causing-error?newreg=7c6019c0d0ae483c8bb3af387166ce49
commands.add(ifExecutableElse1("yum",
chainGroup(
"echo yum exists, doing update",
ok(sudo("yum check-update")),
ok(sudo("yum -y install epel-release")),
ok(sudo("yum upgrade -y ca-certificates --disablerepo=epel")),
sudo(yumInstall))));
if (brewInstall != null)
commands.add(ifExecutableElse1("brew", brewInstall));
if (portInstall != null)
commands.add(ifExecutableElse1("port", sudo(portInstall)));
String lastCommand = ok(warn("WARNING: no known/successful package manager to install " +
(packageDefaultName!=null ? packageDefaultName : flags.toString()) +
", may fail subsequently"));
if (optionalCommandToRunIfNone != null)
lastCommand = chain(lastCommand, optionalCommandToRunIfNone);
commands.add(lastCommand);
return alternatives(commands);
}
public static String warn(String message) {
return "( echo "+BashStringEscapes.wrapBash(message)+" | tee /dev/stderr )";
}
/** returns a command which logs a message to stdout and stderr then exits with the given error code */
public static String fail(String message, int code) {
return chainGroup(warn(message), "exit "+code);
}
/** requires the command to have a non-zero exit code; e.g.
* <code>require("which foo", "Command foo must be found", 1)</code> */
public static String require(String command, String failureMessage, int exitCode) {
return alternativesGroup(command, fail(failureMessage, exitCode));
}
/** as {@link #require(String, String, int)} but returning the original exit code */
public static String require(String command, String failureMessage) {
return alternativesGroup(command, chainGroup("EXIT_CODE=$?", warn(failureMessage), "exit $EXIT_CODE"));
}
/** requires the test to pass, as valid bash `test` arguments; e.g.
* <code>requireTest("-f /etc/hosts", "Hosts file must exist", 1)</code> */
public static String requireTest(String test, String failureMessage, int exitCode) {
return require("test "+test, failureMessage, exitCode);
}
/** as {@link #requireTest(String, String, int)} but returning the original exit code */
public static String requireTest(String test, String failureMessage) {
return require("test "+test, failureMessage);
}
/** fails with nice error if the given file does not exist */
public static String requireFile(String file) {
return requireTest("-f "+BashStringEscapes.wrapBash(file), "The required file \""+file+"\" does not exist");
}
/** fails with nice error if the given file does not exist */
public static String requireExecutable(String command) {
return require("which "+BashStringEscapes.wrapBash(command), "The required executable \""+command+"\" does not exist");
}
public static String waitForFileContents(String file, String desiredContent, Duration timeout, boolean failOnTimeout) {
long secs = Math.max(timeout.toSeconds(), 1);
List<String> commands = ImmutableList.of(
"for i in {1.."+secs+"}; do",
" grep '"+desiredContent+"' "+file+" && result=0 || result=$?",
" [ \"$result\" == 0 ] && break",
" sleep 1",
"done",
"if test \"$result\" -ne 0; then",
" "+ (failOnTimeout ?
"echo \"Couldn't find "+desiredContent+" in "+file+"; aborting\" && exit 1" :
"echo \"Couldn't find "+desiredContent+" in "+file+"; continuing\""),
"fi");
return Joiner.on("\n").join(commands);
}
public static String waitForPortFree(int port, Duration timeout, boolean failOnTimeout) {
long secs = Math.max(timeout.toSeconds(), 1);
// TODO How platform-dependent are the args + output format of netstat?
// TODO Not using sudo as wrapping either netstat call or sudo(alternativesGroup(...)) fails; parentheses too confusing!
String netstatCommand = alternativesGroup(
"sudo netstat -antp --tcp", // for Centos
"sudo netstat -antp TCP"); // for OS X
// number could appear in an IP address or as a port; look for white space at end, and dot or colon before
String grepCommand = "grep -E '(:|\\.)"+port+"($|\\s)' > /dev/null";
List<String> commands = ImmutableList.of(
"for i in {1.."+secs+"}; do",
" "+BashCommands.requireExecutable("netstat"),
" "+alternativesGroup(
chainGroup("which awk", "AWK_EXEC=awk"),
chainGroup("which gawk", "AWK_EXEC=gawk"),
chainGroup("which /usr/bin/awk", "AWK_EXEC=/usr/bin/awk"),
chainGroup("echo \"No awk to determine if Port "+port+" still in use; aborting\"", "exit 1")),
" "+netstatCommand+" | $AWK_EXEC '{print $4}' | "+grepCommand+" && result=0 || result=$?",
" [ \"$result\" != 0 ] && break",
" sleep 1",
"done",
"if test \"$result\" -eq 0; then",
" "+ (failOnTimeout ?
"echo \"Port "+port+" still in use (according to netstat); aborting\" && exit 1" :
"echo \"Port "+port+" still in use (according to netstat); continuing\""),
"fi");
return Joiner.on("\n").join(commands);
}
public static String unzip(String file, String targetDir) {
return "unzip " + file + (Strings.isNonBlank(targetDir) ? " -d "+targetDir : "");
}
public static final String INSTALL_TAR = installExecutable("tar");
public static final String INSTALL_CURL = installExecutable("curl");
public static final String INSTALL_WGET = installExecutable("wget");
public static final String INSTALL_ZIP = installExecutable("zip");
public static final String INSTALL_UNZIP = alternatives(installExecutable("unzip"), installExecutable("zip"));
public static final String INSTALL_SYSSTAT = installPackage(ImmutableMap.of("onlyifmissing", "iostat"), "sysstat");
/**
* Returns commands to download the URL, saving as the given file. Will try each URL in turn until one is successful
* (see `curl -f` documentation).
*/
public static List<String> commandsToDownloadUrlsAs(List<String> urls, String saveAs) {
return Arrays.asList(INSTALL_CURL,
require(simpleDownloadUrlAs(urls, saveAs), "Could not retrieve "+saveAs+". Tried: " + Joiner.on(", ").join(urls), 9));
}
public static String commandToDownloadUrlsAs(List<String> urls, String saveAs) {
return chain(INSTALL_CURL,
require(simpleDownloadUrlAs(urls, saveAs), "Could not retrieve "+saveAs+". Tried: " + Joiner.on(", ").join(urls), 9));
}
public static String commandToDownloadUrlAs(String url, String saveAs) {
return chain(INSTALL_CURL,
require(simpleDownloadUrlAs(Arrays.asList(url), saveAs), "Could not retrieve "+saveAs+" from " + url, 9));
}
/**
* Returns command to download the URL, sending the output to stdout --
* suitable for redirect by appending " | tar xvf".
* Will try each URL in turn until one is successful
*/
public static String downloadToStdout(List<String> urls) {
return chain(
INSTALL_CURL + " > /dev/null",
require(simpleDownloadUrlAs(urls, null),
"Could not retrieve file. Tried: " + Joiner.on(", ").join(urls), 9));
}
/** as {@link #downloadToStdout(List)} but varargs for convenience */
public static String downloadToStdout(String ...urls) {
return downloadToStdout(Arrays.asList(urls));
}
/**
* Same as {@link downloadUrlAs(List, String)}, except does not install curl, and does not exit on failure,
* and if saveAs is null it downloads it so stdout.
*/
public static String simpleDownloadUrlAs(List<String> urls, String saveAs) {
return simpleDownloadUrlAs(urls, null, null, saveAs);
}
public static String simpleDownloadUrlAs(List<String> urls, String user, String password, String saveAs) {
if (urls.isEmpty()) throw new IllegalArgumentException("No URLs supplied to download "+saveAs);
List<String> commands = new ArrayList<String>();
for (String url : urls) {
String command = "curl -f -L -k --retry 10 --keepalive-time 30 --speed-time 30 ";
if (user!=null && password!=null) {
command = command + format("-u %s:%s ", user, password);
}
command = command + format("\"%s\"", url);
if (saveAs!=null) {
command = command + format(" -o %s", saveAs);
}
commands.add(command);
}
return alternatives(commands);
}
private static Object getFlag(Map<?,?> flags, String flagName, Object defaultValue) {
Object found = flags.get(flagName);
return found == null ? defaultValue : found;
}
/**
* Install a particular Java runtime, fails if not possible.
* <p>
* <em><strong>Note</strong> Java 8 is not yet supported on SUSE</em>
*
* @return The command to install the given Java runtime.
* @see #installJava6OrFail()
* @see #installJava7Or6OrFail()
* @see #installJavaLatestOrFail()
*/
public static String installJava(int version) {
Preconditions.checkArgument(version == 6 || version == 7 || version == 8, "Supported Java versions are 6, 7, or 8");
return installPackageOr(MutableMap.of("apt", "openjdk-" + version + "-jdk","yum", "java-1." + version + ".0-openjdk-devel"), null,
ifExecutableElse1("zypper", chainGroup(
ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/SLE_11_SP3 java_sles_11")),
ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/openSUSE_11.4 java_suse_11")),
ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/openSUSE_12.3 java_suse_12")),
ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/openSUSE_13.1 java_suse_13")),
alternatives(installPackageOrFail(MutableMap.of("zypper", "java-1_" + version + "_0-openjdk-devel"), null),
installPackageOrFail(MutableMap.of("zypper", "java-1_" + version + "_0-ibm"), null)))));
}
public static String installJava6() {
return installJava(6);
}
public static String installJava7() {
return installJava(7);
}
public static String installJava8() {
return installJava(8);
}
public static String installJava6IfPossible() {
return ok(installJava6());
}
public static String installJava7IfPossible() {
return ok(installJava7());
}
public static String installJava8IfPossible() {
return ok(installJava8());
}
public static String installJava6OrFail() {
return alternatives(installJava6(), fail("java 6 install failed", 9));
}
public static String installJava7OrFail() {
return alternatives(installJava7(), fail("java 7 install failed", 9));
}
public static String installJava7Or6OrFail() {
return alternatives(installJava7(), installJava6(), fail("java install failed", 9));
}
public static String installJavaLatestOrFail() {
return alternatives(installJava8(), installJava7(), installJava6(), fail("java latest install failed", 9));
}
public static String installJavaLatestOrWarn() {
return alternatives(installJava8(), installJava7(), installJava6(), warn("java latest install failed, entity may subsequently fail"));
}
/** cats the given text to the given command, using bash << multi-line input syntax */
public static String pipeTextTo(String text, String command) {
return "cat << EOL_BROOKLYN | "+command+"\n"
+text
+"\n"+"EOL_BROOKLYN\n";
}
public static String pipeTextToFile(String text, String filepath) {
return "cat > \"" + filepath + "\" << EOF_BROOKLYN\n"
+ text + "\n"
+ "EOF_BROOKLYN\n";
}
public static String prependToEtcHosts(String ip, String... hostnames) {
String tempFileId = "bak"+Identifiers.makeRandomId(4);
return sudo(String.format("sed -i."+tempFileId+" -e '1i\\\n%s %s' /etc/hosts", ip, Joiner.on(" ").join(hostnames)));
}
public static String appendToEtcHosts(String ip, String... hostnames) {
// Using sed rather than `echo ... >> /etc/hosts` because when embedded inside sudo,
// the redirect doesn't get executed by sudo.
String tempFileId = "bak"+Identifiers.makeRandomId(4);
return sudo(String.format("sed -i."+tempFileId+" -e '$a\\\n%s %s' /etc/hosts", ip, Joiner.on(" ").join(hostnames)));
}
/**
* Sets the hostname, splitting the given hostname if it contains a dot to include the unqualified and fully qualified names.
*
* @see {@link #setHostname(String, String)}
*/
@Beta
public static List<String> setHostname(String newHostname) {
// See http://www.dns-sd.org/trailingdotsindomainnames.html.
// If we are given "abcd." then let's pass that as-is to setHostname("abcd.", null)
if (newHostname.indexOf(".") > 0) {
String hostPart = newHostname.substring(0, newHostname.indexOf("."));
String domainPart = newHostname.substring(hostPart.length()+1);
return setHostname(hostPart, domainPart);
} else {
return setHostname(newHostname, null);
}
}
/**
* Sets the hostname to {@code hostPart + "." + domainPart}, or if domainPart is null/empty then {code hostPart}.
*
* @param hostPart
* @param domainPart
* @return
*/
@Beta
public static List<String> setHostname(String hostPart, String domainPart) {
// See:
// - http://www.rackspace.com/knowledge_center/article/centos-hostname-change
// - https://wiki.debian.org/HowTo/ChangeHostname
// - http://askubuntu.com/questions/9540/how-do-i-change-the-computer-name
//
// We prepend in /etc/hosts, to ensure the right fqn appears first.
// e.g. comment in http://askubuntu.com/questions/158957/how-to-set-the-fully-qualified-domain-name-in-12-04
// says "It's important to note that the first domain in /etc/hosts should be your FQDN. "
//
// TODO Should we run `sudo service hostname restart` or `sudo /etc/init.d/hostname restart`?
// I don't think we need to because we've run `sudo hostname <newname>`
//
// TODO What if /etc/sysconfig/network doesn't have a line for HOSTNAME=...?
//
// TODO What about hostPart ending in "." - see http://www.dns-sd.org/trailingdotsindomainnames.html
// for what that means in DNS. However, hostname is not the same as the DNS name (hostnames
// predate the invention of DNS! - although frequently the DNS name has the same first portion
// as the hostname) so the link you gave is not relevant. However despite searching Google and
// man pages I [Ricard] am unable to find a reference which clearly states what characters are
// relevant in a hostname. I think it's safest to assume that the hostname is just [a-z,0-9,-]
// and no dots at all.
checkNotNull(hostPart, "hostPart");
checkArgument(!hostPart.contains("."), "hostPart '%s' must not contain '.'", hostPart);
String tempFileId = "bak"+Identifiers.makeRandomId(4);
List<String> allhostnames = Lists.newArrayList();
String fqdn = hostPart;
if (Strings.isNonBlank(domainPart)) {
fqdn = hostPart+"."+domainPart;
allhostnames.add(fqdn);
}
allhostnames.add(hostPart);
allhostnames.add("localhost");
return ImmutableList.of(
sudo("sed -i."+tempFileId+" -e 's/^127.0.0.1/# Replaced by Brooklyn\\\n#127.0.0.1/' /etc/hosts"),
prependToEtcHosts("127.0.0.1", allhostnames.toArray(new String[allhostnames.size()])),
ifFileExistsElse0("/etc/sysconfig/network", sudo("sed -i."+tempFileId+" -e 's/^HOSTNAME=.*$/HOSTNAME="+hostPart+"/' /etc/sysconfig/network")),
ifFileExistsElse0("/etc/hostname", sudo("sed -i."+tempFileId+" -e 's/^[a-zA-Z_0-9].*$/"+hostPart+"/' /etc/hostname")),
sudo("hostname "+hostPart));
}
}
|
apache/pulsar | 36,641 | pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.pulsar.broker.stats.prometheus;
import io.netty.util.concurrent.FastThreadLocal;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.LongAdder;
import java.util.function.Function;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.client.LedgerHandle;
import org.apache.bookkeeper.mledger.ManagedLedger;
import org.apache.bookkeeper.mledger.impl.ManagedLedgerMBeanImpl;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.pulsar.broker.PulsarService;
import org.apache.pulsar.broker.service.Topic;
import org.apache.pulsar.broker.service.persistent.PersistentTopic;
import org.apache.pulsar.broker.service.persistent.PersistentTopicMetrics;
import org.apache.pulsar.broker.service.persistent.PersistentTopicMetrics.BacklogQuotaMetrics;
import org.apache.pulsar.broker.stats.prometheus.metrics.PrometheusLabels;
import org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType;
import org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl;
import org.apache.pulsar.common.policies.data.stats.NonPersistentSubscriptionStatsImpl;
import org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImpl;
import org.apache.pulsar.common.policies.data.stats.ReplicatorStatsImpl;
import org.apache.pulsar.common.policies.data.stats.SubscriptionStatsImpl;
import org.apache.pulsar.common.policies.data.stats.TopicStatsImpl;
import org.apache.pulsar.compaction.CompactedTopicContext;
import org.apache.pulsar.compaction.Compactor;
import org.apache.pulsar.compaction.CompactorMXBean;
@Slf4j
public class NamespaceStatsAggregator {
private static final FastThreadLocal<AggregatedBrokerStats> localBrokerStats =
new FastThreadLocal<>() {
@Override
protected AggregatedBrokerStats initialValue() {
return new AggregatedBrokerStats();
}
};
private static final FastThreadLocal<AggregatedNamespaceStats> localNamespaceStats =
new FastThreadLocal<>() {
@Override
protected AggregatedNamespaceStats initialValue() {
return new AggregatedNamespaceStats();
}
};
private static final FastThreadLocal<TopicStats> localTopicStats = new FastThreadLocal<>() {
@Override
protected TopicStats initialValue() {
return new TopicStats();
}
};
public static void generate(PulsarService pulsar, boolean includeTopicMetrics, boolean includeConsumerMetrics,
boolean includeProducerMetrics, boolean splitTopicAndPartitionIndexLabel,
PrometheusMetricStreams stream) {
String cluster = pulsar.getConfiguration().getClusterName();
AggregatedBrokerStats brokerStats = localBrokerStats.get();
brokerStats.reset();
AggregatedNamespaceStats namespaceStats = localNamespaceStats.get();
TopicStats topicStats = localTopicStats.get();
Optional<CompactorMXBean> compactorMXBean = getCompactorMXBean(pulsar);
LongAdder topicsCount = new LongAdder();
Map<String, Long> localNamespaceTopicCount = new HashMap<>();
pulsar.getBrokerService().getMultiLayerTopicsMap().forEach((namespace, bundlesMap) -> {
namespaceStats.reset();
topicsCount.reset();
bundlesMap.forEach((bundle, topicsMap) -> topicsMap.forEach((name, topic) -> {
getTopicStats(topic, topicStats, includeConsumerMetrics, includeProducerMetrics,
pulsar.getConfiguration().isExposePreciseBacklogInPrometheus(),
pulsar.getConfiguration().isExposeSubscriptionBacklogSizeInPrometheus(),
compactorMXBean
);
brokerStats.updateStats(topicStats);
if (includeTopicMetrics) {
topicsCount.add(1);
TopicStats.printTopicStats(stream, topicStats, compactorMXBean, cluster, namespace, name,
splitTopicAndPartitionIndexLabel);
} else {
namespaceStats.updateStats(topicStats);
}
}));
if (!includeTopicMetrics) {
// Only include namespace level stats if we don't have the per-topic, otherwise we're going to
// report the same data twice, and it will make the aggregation difficult
printNamespaceStats(stream, namespaceStats, cluster, namespace);
} else {
localNamespaceTopicCount.put(namespace, topicsCount.sum());
}
});
if (includeTopicMetrics) {
printTopicsCountStats(stream, localNamespaceTopicCount, cluster);
}
printBrokerStats(stream, cluster, brokerStats);
}
private static Optional<CompactorMXBean> getCompactorMXBean(PulsarService pulsar) {
Compactor compactor = pulsar.getNullableCompactor();
return Optional.ofNullable(compactor).map(Compactor::getStats);
}
private static void aggregateTopicStats(TopicStats stats, SubscriptionStatsImpl subscriptionStats,
AggregatedSubscriptionStats subsStats) {
stats.subscriptionsCount++;
stats.msgBacklog += subscriptionStats.msgBacklog;
subsStats.bytesOutCounter = subscriptionStats.bytesOutCounter;
subsStats.msgOutCounter = subscriptionStats.msgOutCounter;
subsStats.msgBacklog = subscriptionStats.msgBacklog;
subsStats.msgDelayed = subscriptionStats.msgDelayed;
subsStats.msgInReplay = subscriptionStats.msgInReplay;
subsStats.msgRateExpired = subscriptionStats.msgRateExpired;
subsStats.totalMsgExpired = subscriptionStats.totalMsgExpired;
subsStats.msgBacklogNoDelayed = subsStats.msgBacklog - subsStats.msgDelayed;
subsStats.lastExpireTimestamp = subscriptionStats.lastExpireTimestamp;
subsStats.lastAckedTimestamp = subscriptionStats.lastAckedTimestamp;
subsStats.lastConsumedFlowTimestamp = subscriptionStats.lastConsumedFlowTimestamp;
subsStats.lastConsumedTimestamp = subscriptionStats.lastConsumedTimestamp;
subsStats.lastMarkDeleteAdvancedTimestamp = subscriptionStats.lastMarkDeleteAdvancedTimestamp;
subsStats.consumersCount = subscriptionStats.consumers.size();
subsStats.blockedSubscriptionOnUnackedMsgs = subscriptionStats.blockedSubscriptionOnUnackedMsgs;
subscriptionStats.consumers.forEach(cStats -> {
stats.consumersCount++;
subsStats.unackedMessages += cStats.unackedMessages;
subsStats.msgRateRedeliver += cStats.msgRateRedeliver;
subsStats.msgRateOut += cStats.msgRateOut;
subsStats.messageAckRate += cStats.messageAckRate;
subsStats.msgThroughputOut += cStats.msgThroughputOut;
});
stats.rateOut += subsStats.msgRateOut;
stats.throughputOut += subsStats.msgThroughputOut;
subsStats.filterProcessedMsgCount = subscriptionStats.filterProcessedMsgCount;
subsStats.filterAcceptedMsgCount = subscriptionStats.filterAcceptedMsgCount;
subsStats.filterRejectedMsgCount = subscriptionStats.filterRejectedMsgCount;
subsStats.filterRescheduledMsgCount = subscriptionStats.filterRescheduledMsgCount;
subsStats.delayedMessageIndexSizeInBytes = subscriptionStats.delayedMessageIndexSizeInBytes;
subsStats.bucketDelayedIndexStats = subscriptionStats.bucketDelayedIndexStats;
subsStats.dispatchThrottledMsgEventsBySubscriptionLimit =
subscriptionStats.dispatchThrottledMsgEventsBySubscriptionLimit;
subsStats.dispatchThrottledBytesEventsBySubscriptionLimit =
subscriptionStats.dispatchThrottledBytesEventsBySubscriptionLimit;
subsStats.dispatchThrottledMsgEventsByTopicLimit =
subscriptionStats.dispatchThrottledMsgEventsByTopicLimit;
subsStats.dispatchThrottledBytesEventsByTopicLimit =
subscriptionStats.dispatchThrottledBytesEventsByTopicLimit;
subsStats.dispatchThrottledMsgEventsByBrokerLimit =
subscriptionStats.dispatchThrottledMsgEventsByBrokerLimit;
subsStats.dispatchThrottledBytesEventsByBrokerLimit =
subscriptionStats.dispatchThrottledBytesEventsByBrokerLimit;
}
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private static void getTopicStats(Topic topic, TopicStats stats, boolean includeConsumerMetrics,
boolean includeProducerMetrics, boolean getPreciseBacklog,
boolean subscriptionBacklogSize, Optional<CompactorMXBean> compactorMXBean) {
stats.reset();
if (topic instanceof PersistentTopic persistentTopic) {
// Managed Ledger stats
ManagedLedger ml = persistentTopic.getManagedLedger();
ManagedLedgerMBeanImpl mlStats = (ManagedLedgerMBeanImpl) ml.getStats();
stats.managedLedgerStats.storageSize = mlStats.getStoredMessagesSize();
stats.managedLedgerStats.storageLogicalSize = mlStats.getStoredMessagesLogicalSize();
stats.managedLedgerStats.backlogSize = ml.getEstimatedBacklogSize();
stats.managedLedgerStats.offloadedStorageUsed = ml.getOffloadedSize();
stats.backlogQuotaLimit = topic
.getBacklogQuota(BacklogQuotaType.destination_storage).getLimitSize();
stats.backlogQuotaLimitTime = topic
.getBacklogQuota(BacklogQuotaType.message_age).getLimitTime();
stats.backlogAgeSeconds = topic.getBestEffortOldestUnacknowledgedMessageAgeSeconds();
stats.managedLedgerStats.storageWriteLatencyBuckets
.addAll(mlStats.getInternalAddEntryLatencyBuckets());
stats.managedLedgerStats.storageWriteLatencyBuckets.refresh();
stats.managedLedgerStats.storageLedgerWriteLatencyBuckets
.addAll(mlStats.getInternalLedgerAddEntryLatencyBuckets());
stats.managedLedgerStats.storageLedgerWriteLatencyBuckets.refresh();
stats.managedLedgerStats.entrySizeBuckets.addAll(mlStats.getInternalEntrySizeBuckets());
stats.managedLedgerStats.entrySizeBuckets.refresh();
stats.managedLedgerStats.storageWriteRate = mlStats.getAddEntryMessagesRate();
stats.managedLedgerStats.storageReadRate = mlStats.getReadEntriesRate();
stats.managedLedgerStats.storageReadCacheMissesRate = mlStats.getReadEntriesOpsCacheMissesRate();
// Topic Stats
PersistentTopicMetrics persistentTopicMetrics = persistentTopic.getPersistentTopicMetrics();
BacklogQuotaMetrics backlogQuotaMetrics = persistentTopicMetrics.getBacklogQuotaMetrics();
stats.sizeBasedBacklogQuotaExceededEvictionCount =
backlogQuotaMetrics.getSizeBasedBacklogQuotaExceededEvictionCount();
stats.timeBasedBacklogQuotaExceededEvictionCount =
backlogQuotaMetrics.getTimeBasedBacklogQuotaExceededEvictionCount();
}
TopicStatsImpl tStatus = topic.getStats(getPreciseBacklog, subscriptionBacklogSize, false);
stats.msgInCounter = tStatus.msgInCounter;
stats.bytesInCounter = tStatus.bytesInCounter;
stats.msgOutCounter = tStatus.msgOutCounter;
stats.systemTopicBytesInCounter = tStatus.systemTopicBytesInCounter;
stats.bytesOutInternalCounter = tStatus.getBytesOutInternalCounter();
stats.bytesOutCounter = tStatus.bytesOutCounter;
stats.averageMsgSize = tStatus.averageMsgSize;
stats.publishRateLimitedTimes = tStatus.publishRateLimitedTimes;
stats.delayedMessageIndexSizeInBytes = tStatus.delayedMessageIndexSizeInBytes;
stats.bucketDelayedIndexStats = tStatus.bucketDelayedIndexStats;
stats.abortedTxnCount = tStatus.abortedTxnCount;
stats.ongoingTxnCount = tStatus.ongoingTxnCount;
stats.committedTxnCount = tStatus.committedTxnCount;
stats.producersCount = 0;
topic.getProducers().values().forEach(producer -> {
if (producer.isRemote()) {
AggregatedReplicationStats replStats = stats.replicationStats
.computeIfAbsent(producer.getRemoteCluster(), k -> new AggregatedReplicationStats());
replStats.msgRateIn += producer.getStats().msgRateIn;
replStats.msgThroughputIn += producer.getStats().msgThroughputIn;
} else {
// Local producer
stats.producersCount++;
stats.rateIn += producer.getStats().msgRateIn;
stats.throughputIn += producer.getStats().msgThroughputIn;
if (includeProducerMetrics) {
AggregatedProducerStats producerStats = stats.producerStats.computeIfAbsent(
producer.getProducerName(), k -> new AggregatedProducerStats());
producerStats.producerId = producer.getStats().producerId;
producerStats.msgRateIn = producer.getStats().msgRateIn;
producerStats.msgThroughputIn = producer.getStats().msgThroughputIn;
producerStats.averageMsgSize = producer.getStats().averageMsgSize;
}
}
});
if (topic instanceof PersistentTopic) {
tStatus.subscriptions.forEach((subName, subscriptionStats) -> {
AggregatedSubscriptionStats subsStats = stats.subscriptionStats
.computeIfAbsent(subName, k -> new AggregatedSubscriptionStats());
aggregateTopicStats(stats, subscriptionStats, subsStats);
});
} else {
((NonPersistentTopicStatsImpl) tStatus).getNonPersistentSubscriptions()
.forEach((subName, nonPersistentSubscriptionStats) -> {
NonPersistentSubscriptionStatsImpl subscriptionStats =
(NonPersistentSubscriptionStatsImpl) nonPersistentSubscriptionStats;
AggregatedSubscriptionStats subsStats = stats.subscriptionStats
.computeIfAbsent(subName, k -> new AggregatedSubscriptionStats());
aggregateTopicStats(stats, subscriptionStats, subsStats);
subsStats.msgDropRate += subscriptionStats.getMsgDropRate();
});
}
// Consumer stats can be a lot if a subscription has many consumers
if (includeConsumerMetrics) {
topic.getSubscriptions().forEach((name, subscription) -> {
AggregatedSubscriptionStats subsStats = stats.subscriptionStats
.computeIfAbsent(name, k -> new AggregatedSubscriptionStats());
subscription.getConsumers().forEach(consumer -> {
ConsumerStatsImpl conStats = consumer.getStats();
AggregatedConsumerStats consumerStats = subsStats.consumerStat
.computeIfAbsent(consumer, k -> new AggregatedConsumerStats());
consumerStats.unackedMessages = conStats.unackedMessages;
consumerStats.msgRateRedeliver = conStats.msgRateRedeliver;
consumerStats.msgRateOut = conStats.msgRateOut;
consumerStats.msgAckRate = conStats.messageAckRate;
consumerStats.msgThroughputOut = conStats.msgThroughputOut;
consumerStats.bytesOutCounter = conStats.bytesOutCounter;
consumerStats.msgOutCounter = conStats.msgOutCounter;
consumerStats.availablePermits = conStats.availablePermits;
consumerStats.blockedSubscriptionOnUnackedMsgs = conStats.blockedConsumerOnUnackedMsgs;
});
});
}
topic.getReplicators().forEach((cluster, replicator) -> {
ReplicatorStatsImpl replStats = replicator.computeStats();
AggregatedReplicationStats aggReplStats = stats.replicationStats.get(replicator.getRemoteCluster());
if (aggReplStats == null) {
aggReplStats = new AggregatedReplicationStats();
stats.replicationStats.put(replicator.getRemoteCluster(), aggReplStats);
aggReplStats.msgRateIn = replStats.msgRateIn;
aggReplStats.msgThroughputIn = replStats.msgThroughputIn;
}
aggReplStats.msgRateOut += replStats.msgRateOut;
aggReplStats.msgThroughputOut += replStats.msgThroughputOut;
aggReplStats.replicationBacklog += replStats.replicationBacklog;
aggReplStats.msgRateExpired += replStats.msgRateExpired;
if (replStats.connected) {
aggReplStats.connectedCount += 1;
} else {
aggReplStats.disconnectedCount += 1;
}
aggReplStats.replicationDelayInSeconds += replStats.replicationDelayInSeconds;
});
compactorMXBean
.flatMap(mxBean -> mxBean.getCompactionRecordForTopic(topic.getName()))
.map(compactionRecord -> {
stats.compactionRemovedEventCount = compactionRecord.getCompactionRemovedEventCount();
stats.compactionSucceedCount = compactionRecord.getCompactionSucceedCount();
stats.compactionFailedCount = compactionRecord.getCompactionFailedCount();
stats.compactionDurationTimeInMills = compactionRecord.getCompactionDurationTimeInMills();
stats.compactionReadThroughput = compactionRecord.getCompactionReadThroughput();
stats.compactionWriteThroughput = compactionRecord.getCompactionWriteThroughput();
stats.compactionLatencyBuckets.addAll(compactionRecord.getCompactionLatencyStats());
stats.compactionLatencyBuckets.refresh();
PersistentTopic persistentTopic = (PersistentTopic) topic;
Optional<CompactedTopicContext> compactedTopicContext = persistentTopic
.getCompactedTopicContext();
if (compactedTopicContext.isPresent()) {
LedgerHandle ledger = compactedTopicContext.get().getLedger();
long entries = ledger.getLastAddConfirmed() + 1;
long size = ledger.getLength();
stats.compactionCompactedEntriesCount = entries;
stats.compactionCompactedEntriesSize = size;
}
return compactionRecord;
});
}
private static void printBrokerStats(PrometheusMetricStreams stream, String cluster,
AggregatedBrokerStats brokerStats) {
// Print metrics values. This is necessary to have the available brokers being
// reported in the brokers dashboard even if they don't have any topic or traffic
writeMetric(stream, "pulsar_broker_topics_count", brokerStats.topicsCount, cluster);
writeMetric(stream, "pulsar_broker_subscriptions_count", brokerStats.subscriptionsCount, cluster);
writeMetric(stream, "pulsar_broker_producers_count", brokerStats.producersCount, cluster);
writeMetric(stream, "pulsar_broker_consumers_count", brokerStats.consumersCount, cluster);
writeMetric(stream, "pulsar_broker_rate_in", brokerStats.rateIn, cluster);
writeMetric(stream, "pulsar_broker_rate_out", brokerStats.rateOut, cluster);
writeMetric(stream, "pulsar_broker_throughput_in", brokerStats.throughputIn, cluster);
writeMetric(stream, "pulsar_broker_throughput_out", brokerStats.throughputOut, cluster);
writeMetric(stream, "pulsar_broker_storage_size", brokerStats.storageSize, cluster);
writeMetric(stream, "pulsar_broker_storage_logical_size", brokerStats.storageLogicalSize, cluster);
writeMetric(stream, "pulsar_broker_storage_write_rate", brokerStats.storageWriteRate, cluster);
writeMetric(stream, "pulsar_broker_storage_read_rate", brokerStats.storageReadRate, cluster);
writeMetric(stream, "pulsar_broker_storage_read_cache_misses_rate",
brokerStats.storageReadCacheMissesRate, cluster);
writePulsarBacklogQuotaMetricBrokerLevel(stream,
"pulsar_broker_storage_backlog_quota_exceeded_evictions_total",
brokerStats.sizeBasedBacklogQuotaExceededEvictionCount, cluster, BacklogQuotaType.destination_storage);
writePulsarBacklogQuotaMetricBrokerLevel(stream,
"pulsar_broker_storage_backlog_quota_exceeded_evictions_total",
brokerStats.timeBasedBacklogQuotaExceededEvictionCount, cluster, BacklogQuotaType.message_age);
writeMetric(stream, "pulsar_broker_msg_backlog", brokerStats.msgBacklog, cluster);
long userOutBytes = brokerStats.bytesOutCounter - brokerStats.bytesOutInternalCounter;
writeMetric(stream, "pulsar_broker_out_bytes_total",
userOutBytes, cluster, "system_subscription", "false");
writeMetric(stream, "pulsar_broker_out_bytes_total",
brokerStats.bytesOutInternalCounter, cluster, "system_subscription", "true");
long userTopicInBytes = brokerStats.bytesInCounter - brokerStats.systemTopicBytesInCounter;
writeMetric(stream, "pulsar_broker_in_bytes_total",
userTopicInBytes, cluster, "system_topic", "false");
writeMetric(stream, "pulsar_broker_in_bytes_total",
brokerStats.systemTopicBytesInCounter, cluster, "system_topic", "true");
}
private static void printTopicsCountStats(PrometheusMetricStreams stream, Map<String, Long> namespaceTopicsCount,
String cluster) {
namespaceTopicsCount.forEach(
(ns, topicCount) -> writeMetric(stream, "pulsar_topics_count", topicCount, cluster, ns)
);
}
private static void printNamespaceStats(PrometheusMetricStreams stream, AggregatedNamespaceStats stats,
String cluster, String namespace) {
writeMetric(stream, "pulsar_topics_count", stats.topicsCount, cluster, namespace);
writeMetric(stream, "pulsar_subscriptions_count", stats.subscriptionsCount, cluster,
namespace);
writeMetric(stream, "pulsar_producers_count", stats.producersCount, cluster, namespace);
writeMetric(stream, "pulsar_consumers_count", stats.consumersCount, cluster, namespace);
writeMetric(stream, "pulsar_rate_in", stats.rateIn, cluster, namespace);
writeMetric(stream, "pulsar_rate_out", stats.rateOut, cluster, namespace);
writeMetric(stream, "pulsar_throughput_in", stats.throughputIn, cluster, namespace);
writeMetric(stream, "pulsar_throughput_out", stats.throughputOut, cluster, namespace);
writeMetric(stream, "pulsar_txn_tb_active_total", stats.ongoingTxnCount, cluster, namespace);
writeMetric(stream, "pulsar_txn_tb_aborted_total", stats.abortedTxnCount, cluster, namespace);
writeMetric(stream, "pulsar_txn_tb_committed_total", stats.committedTxnCount, cluster, namespace);
writeMetric(stream, "pulsar_consumer_msg_ack_rate", stats.messageAckRate, cluster, namespace);
writeMetric(stream, "pulsar_in_bytes_total", stats.bytesInCounter, cluster, namespace);
writeMetric(stream, "pulsar_in_messages_total", stats.msgInCounter, cluster, namespace);
writeMetric(stream, "pulsar_out_bytes_total", stats.bytesOutCounter, cluster, namespace);
writeMetric(stream, "pulsar_out_messages_total", stats.msgOutCounter, cluster, namespace);
writeMetric(stream, "pulsar_storage_size", stats.managedLedgerStats.storageSize, cluster,
namespace);
writeMetric(stream, "pulsar_storage_logical_size",
stats.managedLedgerStats.storageLogicalSize, cluster, namespace);
writeMetric(stream, "pulsar_storage_backlog_size", stats.managedLedgerStats.backlogSize, cluster,
namespace);
writeMetric(stream, "pulsar_storage_offloaded_size",
stats.managedLedgerStats.offloadedStorageUsed, cluster, namespace);
writeMetric(stream, "pulsar_storage_write_rate", stats.managedLedgerStats.storageWriteRate,
cluster, namespace);
writeMetric(stream, "pulsar_storage_read_rate", stats.managedLedgerStats.storageReadRate,
cluster, namespace);
writeMetric(stream, "pulsar_storage_read_cache_misses_rate",
stats.managedLedgerStats.storageReadCacheMissesRate, cluster, namespace);
writeMetric(stream, "pulsar_subscription_delayed", stats.msgDelayed, cluster, namespace);
writeMetric(stream, "pulsar_subscription_in_replay", stats.msgInReplay, cluster, namespace);
writeMetric(stream, "pulsar_delayed_message_index_size_bytes", stats.delayedMessageIndexSizeInBytes, cluster,
namespace);
stats.bucketDelayedIndexStats.forEach((k, metric) -> {
String[] labels = ArrayUtils.addAll(new String[]{"namespace", namespace}, metric.labelsAndValues);
writeMetric(stream, metric.name, metric.value, cluster, labels);
});
writePulsarMsgBacklog(stream, stats.msgBacklog, cluster, namespace);
writePulsarBacklogQuotaMetricNamespaceLevel(stream,
"pulsar_storage_backlog_quota_exceeded_evictions_total",
stats.sizeBasedBacklogQuotaExceededEvictionCount, cluster, namespace,
BacklogQuotaType.destination_storage);
writePulsarBacklogQuotaMetricNamespaceLevel(stream,
"pulsar_storage_backlog_quota_exceeded_evictions_total",
stats.timeBasedBacklogQuotaExceededEvictionCount, cluster, namespace,
BacklogQuotaType.message_age);
stats.managedLedgerStats.storageWriteLatencyBuckets.refresh();
long[] latencyBuckets = stats.managedLedgerStats.storageWriteLatencyBuckets.getBuckets();
writeMetric(stream, "pulsar_storage_write_latency_le_0_5", latencyBuckets[0], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_1", latencyBuckets[1], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_5", latencyBuckets[2], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_10", latencyBuckets[3], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_20", latencyBuckets[4], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_50", latencyBuckets[5], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_100", latencyBuckets[6], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_200", latencyBuckets[7], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_le_1000", latencyBuckets[8], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_overflow", latencyBuckets[9], cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_count",
stats.managedLedgerStats.storageWriteLatencyBuckets.getCount(), cluster, namespace);
writeMetric(stream, "pulsar_storage_write_latency_sum",
stats.managedLedgerStats.storageWriteLatencyBuckets.getSum(), cluster, namespace);
stats.managedLedgerStats.storageLedgerWriteLatencyBuckets.refresh();
long[] ledgerWriteLatencyBuckets = stats.managedLedgerStats.storageLedgerWriteLatencyBuckets.getBuckets();
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_0_5", ledgerWriteLatencyBuckets[0],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_1", ledgerWriteLatencyBuckets[1],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_5", ledgerWriteLatencyBuckets[2],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_10", ledgerWriteLatencyBuckets[3],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_20", ledgerWriteLatencyBuckets[4],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_50", ledgerWriteLatencyBuckets[5],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_100", ledgerWriteLatencyBuckets[6],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_200", ledgerWriteLatencyBuckets[7],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_le_1000", ledgerWriteLatencyBuckets[8],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_overflow", ledgerWriteLatencyBuckets[9],
cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_count",
stats.managedLedgerStats.storageLedgerWriteLatencyBuckets.getCount(), cluster, namespace);
writeMetric(stream, "pulsar_storage_ledger_write_latency_sum",
stats.managedLedgerStats.storageLedgerWriteLatencyBuckets.getSum(), cluster, namespace);
stats.managedLedgerStats.entrySizeBuckets.refresh();
long[] entrySizeBuckets = stats.managedLedgerStats.entrySizeBuckets.getBuckets();
writeMetric(stream, "pulsar_entry_size_le_128", entrySizeBuckets[0], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_512", entrySizeBuckets[1], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_1_kb", entrySizeBuckets[2], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_2_kb", entrySizeBuckets[3], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_4_kb", entrySizeBuckets[4], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_16_kb", entrySizeBuckets[5], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_100_kb", entrySizeBuckets[6], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_1_mb", entrySizeBuckets[7], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_le_overflow", entrySizeBuckets[8], cluster, namespace);
writeMetric(stream, "pulsar_entry_size_count", stats.managedLedgerStats.entrySizeBuckets.getCount(),
cluster, namespace);
writeMetric(stream, "pulsar_entry_size_sum", stats.managedLedgerStats.entrySizeBuckets.getSum(),
cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_rate_in", stats,
replStats -> replStats.msgRateIn, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_rate_out", stats,
replStats -> replStats.msgRateOut, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_throughput_in", stats,
replStats -> replStats.msgThroughputIn, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_throughput_out", stats,
replStats -> replStats.msgThroughputOut, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_backlog", stats,
replStats -> replStats.replicationBacklog, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_connected_count", stats,
replStats -> replStats.connectedCount, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_disconnected_count", stats,
replStats -> replStats.disconnectedCount, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_rate_expired", stats,
replStats -> replStats.msgRateExpired, cluster, namespace);
writeReplicationStat(stream, "pulsar_replication_delay_in_seconds", stats,
replStats -> replStats.replicationDelayInSeconds, cluster, namespace);
}
@SuppressWarnings("SameParameterValue")
private static void writePulsarBacklogQuotaMetricBrokerLevel(PrometheusMetricStreams stream, String metricName,
Number value, String cluster,
BacklogQuotaType backlogQuotaType) {
String quotaTypeLabelValue = PrometheusLabels.backlogQuotaTypeLabel(backlogQuotaType);
stream.writeSample(metricName, value, "cluster", cluster,
"quota_type", quotaTypeLabelValue);
}
@SuppressWarnings("SameParameterValue")
private static void writePulsarBacklogQuotaMetricNamespaceLevel(PrometheusMetricStreams stream, String metricName,
Number value, String cluster, String namespace,
BacklogQuotaType backlogQuotaType) {
String quotaTypeLabelValue = PrometheusLabels.backlogQuotaTypeLabel(backlogQuotaType);
stream.writeSample(metricName, value, "cluster", cluster,
"namespace", namespace,
"quota_type", quotaTypeLabelValue);
}
private static void writePulsarMsgBacklog(PrometheusMetricStreams stream, Number value,
String cluster, String namespace) {
stream.writeSample("pulsar_msg_backlog", value, "cluster", cluster, "namespace", namespace,
"remote_cluster",
"local");
}
private static void writeMetric(PrometheusMetricStreams stream, String metricName, Number value,
String cluster) {
stream.writeSample(metricName, value, "cluster", cluster);
}
private static void writeMetric(PrometheusMetricStreams stream, String metricName, Number value,
String cluster, String... extraLabelsAndValues) {
String[] labels = ArrayUtils.addAll(new String[]{"cluster", cluster}, extraLabelsAndValues);
stream.writeSample(metricName, value, labels);
}
private static void writeMetric(PrometheusMetricStreams stream, String metricName, Number value, String cluster,
String namespace) {
String[] labels = new String[]{"cluster", cluster, "namespace", namespace};
stream.writeSample(metricName, value, labels);
}
private static void writeReplicationStat(PrometheusMetricStreams stream, String metricName,
AggregatedNamespaceStats namespaceStats,
Function<AggregatedReplicationStats, Number> sampleValueFunction,
String cluster, String namespace) {
if (!namespaceStats.replicationStats.isEmpty()) {
namespaceStats.replicationStats.forEach((remoteCluster, replStats) ->
stream.writeSample(metricName, sampleValueFunction.apply(replStats),
"cluster", cluster,
"namespace", namespace,
"remote_cluster", remoteCluster)
);
}
}
}
|
google/closure-compiler | 36,053 | src/com/google/javascript/jscomp/testing/TestExternsBuilder.java | /*
* Copyright 2018 The Closure Compiler Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.javascript.jscomp.testing;
import com.google.common.base.Joiner;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.javascript.jscomp.SourceFile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Builds a string containing standard externs definitions for use in testing.
*
* <p>The externs in this file are intentionally far from complete. Please use the actual externs
* definitions (es3.js, etc.) as a model when you need to add something for a test case.
*/
public class TestExternsBuilder {
// Closure definitions that are not technically externs but serve a similar purpose.
private static final String CLOSURE_EXTERNS =
"""
/** @const */ var goog = {};
goog.module = function(ns) {};
goog.module.declareLegacyNamespace = function() {};
goog.module.preventModuleExportSealing = function() {};
/** @return {?} */
goog.module.get = function(ns) {};
goog.provide = function(ns) {};
/** @return {?} */
goog.require = function(ns) {};
/** @return {?} */
goog.requireType = function(ns) {};
goog.requireDynamic = function(ns) {};
goog.loadModule = function(ns) {};
/** @return {?} */
goog.forwardDeclare = function(ns) {};
goog.setTestOnly = function() {};
goog.scope = function(fn) {};
goog.declareModuleId = function(ns) {};
/**
* @param {string} name
* @param {T} defaultValue
* @return {T}
* @template T
*/
goog.define = function(name, defaultValue) {};
goog.exportSymbol = function(publicName, symbol) {};
goog.inherits = function(childCtor, parentCtor) {
childCtor.superClass_ = parentCtor.prototype;
};
goog.getMsg = function(str) {};
/**
* @param {T} symbol
* @return {T|undefined}
* @template T
* @noinline
*/
goog.weakUsage = function(symbol) {};
""";
/**
* There are some rare cases where we want to use the closure externs defined above as if they
* were sources.
*
* <p>Using this method avoids the automatic addition of the `@fileoverview` comment containing
* `@externs`, which forces the compiler to treat the code as externs definitions.
*/
public static String getClosureExternsAsSource() {
return CLOSURE_EXTERNS;
}
// Runtime library stubs that are not technically externs but serve a similar purpose.
private static final String JSCOMP_LIBRARIES =
"""
/** @const */
var $jscomp = {};
/**
* @param {function(new: ?)} subclass
* @param {function(new: ?)} superclass
*/
$jscomp.inherits = function(subclass, superclass) {};
/**
* @param {!Iterable<T>} iterable
* @return {!Array<T>}
* @template T
*/
$jscomp.arrayFromIterable = function(iterable) {};
/**
* @param {string|!Iterable<T>|!Iterator<T>|!Arguments} iterable
* @return {!Iterator<T>}
* @template T
*/
$jscomp.makeIterator = function(iterable) {};
$jscomp.makeAsyncIterator = function(asyncIterable) {};
/**
* @param {!Iterator<T>} iterator
* @return {!Array<T>}
* @template T
*/
$jscomp.arrayFromIterator = function(iterator) {};
/**
* @param {function(): !Generator<?>} generatorFunction
* @return {!Promise<?>}
*/
$jscomp.asyncExecutePromiseGeneratorFunction = function(generatorFunction) {};
/**
* @type {!Global}
*/
var globalThis;
/** @type {!Global} */
$jscomp.global = globalThis;
/** @const {typeof Reflect.construct} */
$jscomp.construct = Reflect.construct;
/** @constructor */
$jscomp.AsyncGeneratorWrapper = function(generator) {};
/** @constructor */
$jscomp.AsyncGeneratorWrapper$ActionRecord = function(action, value) {};
/** @enum {number} */
$jscomp.AsyncGeneratorWrapper$ActionEnum = {
YIELD_VALUE: 0,
YIELD_STAR: 1,
AWAIT_VALUE: 2,
};\
""";
private static final String BIGINT_EXTERNS =
"""
/**
* @constructor
* @param {bigint|number|string} arg
* @return {bigint}
*/
function BigInt(arg) {}
/**
* @this {BigInt|bigint}
* @param {number} width
* @param {bigint} bigint
* @return {bigint}
*/
BigInt.asIntN = function(width, bigint) {};
/**
* @this {BigInt|bigint}
* @param {number} width
* @param {bigint} bigint
* @return {bigint}
*/
BigInt.asUintN = function(width, bigint) {};
/**
* @param {string|Array<string>=} locales
* @param {?Object=} options
* @return {string}
*/
BigInt.prototype.toLocaleString = function(locales, options) {};
/**
* @this {BigInt|bigint}
* @param {number=} radix
* @return {string}
*/
BigInt.prototype.toString = function(radix) {};
/**
* @return {bigint}
*/
BigInt.prototype.valueOf = function() {};
""";
private static final String ITERABLE_EXTERNS =
"""
// Symbol is needed for Symbol.iterator
/**
* @constructor
* @param {*=} opt_description
* @return {symbol}
* @nosideeffects
*/
function Symbol(opt_description) {}
/** @const {!symbol} */ Symbol.iterator;
/**
* @record
* @template TYield
*/
function IIterableResult() {};
/** @type {boolean} */
IIterableResult.prototype.done;
/** @type {TYield} */
IIterableResult.prototype.value;
/**
* @interface
* @template T, TReturn, TNext
*/
function Iterator() {}
/**
* @param {T=} value
* @return {!IIterableResult<T>}
*/
Iterator.prototype.next;
/**
* @interface
* @template T, TReturn, TNext
*/
function Iterable() {}
/**
* @return {!Iterator<T, ?, *>}}
* @suppress {externsValidation}
*/
Iterable.prototype[Symbol.iterator] = function() {};
/**
* @interface
* @extends {Iterator<T, ?, *>}}
* @extends {Iterable<T, ?, *>}}
* @template T, TReturn, TNext
*/
function IteratorIterable() {}
/**
* @interface
* @extends {IteratorIterable<T, ?, *>}}
* @template T, TReturn, TNext
*/
function Generator() {}
/**
* @param {?=} opt_value
* @return {!IIterableResult<T>}
* @override
*/
Generator.prototype.next = function(opt_value) {};
/**
* @param {T} value
* @return {!IIterableResult<T>}
*/
Generator.prototype.return = function(value) {};
/**
* @param {?} exception
* @return {!IIterableResult<T>}
*/
Generator.prototype.throw = function(exception) {};
""";
private static final String STRING_EXTERNS =
"""
/**
* @constructor
* @implements {Iterable<string>}
* @param {*=} arg
* @return {string}
*/
function String(arg) {}
/** @override @return {!Iterator<string>} */
String.prototype[Symbol.iterator] = function() {};
/** @type {number} */
String.prototype.length;
/** @param {number} sliceArg */
String.prototype.slice = function(sliceArg) {};
/**
* @this {string|!String}
* @param {*=} opt_separator
* @param {number=} opt_limit
* @return {!Array<string>}
*/
String.prototype.split = function(opt_separator, opt_limit) {};
/**
* @this {string|!String}
* @param {string} search_string
* @param {number=} opt_position
* @return {boolean}
* @nosideeffects
*/
String.prototype.startsWith = function(search_string, opt_position) {};
/**
* @this {!String|string}
* @param {?} regex
* @param {?} str
* @param {string=} opt_flags
* @return {string}
*/
String.prototype.replace = function(regex, str, opt_flags) {};
/**
* @this {!String|string}
* @param {number} index
* @return {string}
*/
String.prototype.charAt = function(index) {};
/**
* @this {!String|string}
* @param {*} regexp
* @return {!Array<string>}
*/
String.prototype.match = function(regexp) {};
/**
* @this {!String|string}
* @return {string}
*/
String.prototype.toLowerCase = function() {};
/**
* @param {number} count
* @this {!String|string}
* @return {string}
* @nosideeffects
*/
String.prototype.repeat = function(count) {};
/**
* @param {string} searchString
* @param {number=} position
* @return {boolean}
* @nosideeffects
*/
String.prototype.includes = function(searchString, position) {};
""";
private static final String FUNCTION_EXTERNS =
"""
/**
* @constructor
* @param {...*} var_args
*/
function Function(var_args) {}
/** @type {!Function} */ Function.prototype.apply;
/** @type {!Function} */ Function.prototype.bind;
/** @type {!Function} */ Function.prototype.call;
/** @type {number} */
Function.prototype.length;
/** @type {string} */
Function.prototype.name;
""";
private static final String OBJECT_EXTERNS =
"""
/**
* @record
* @template THIS
*/
function ObjectPropertyDescriptor() {}
/** @type {(*|undefined)} */
ObjectPropertyDescriptor.prototype.value;
/** @type {(function(this: THIS):?)|undefined} */
ObjectPropertyDescriptor.prototype.get;
/** @type {(function(this: THIS, ?):void)|undefined} */
ObjectPropertyDescriptor.prototype.set;
/** @type {boolean|undefined} */
ObjectPropertyDescriptor.prototype.writable;
/** @type {boolean|undefined} */
ObjectPropertyDescriptor.prototype.enumerable;
/** @type {boolean|undefined} */
ObjectPropertyDescriptor.prototype.configurable;
/**
* @constructor
* @param {*=} opt_value
* @return {!Object}
* @template K,V
*/
function Object(opt_value) {}
/** @type {?Object} */ Object.prototype.__proto__;
/** @return {string} */
Object.prototype.toString = function() {};
/**
* @param {*} propertyName
* @return {boolean}
*/
Object.prototype.hasOwnProperty = function(propertyName) {};
/** @type {?Function} */ Object.prototype.constructor;
/** @return {*} */
Object.prototype.valueOf = function() {};
/**
* @param {!Object} obj
* @param {string} prop
* @return {!ObjectPropertyDescriptor|undefined}
* @nosideeffects
*/
Object.getOwnPropertyDescriptor = function(obj, prop) {};
/**
* @param {!Object} obj
* @param {string | symbol} prop
* @param {!ObjectPropertyDescriptor} descriptor
* @return {!Object}
*/
Object.defineProperty = function(obj, prop, descriptor) {};
/**
* @template T
* @param {T} obj
* @param {!Object<string|symbol, !ObjectPropertyDescriptor<T>>} props
* @return {T}
*/
Object.defineProperties = function(obj, props) {};
/**
* @param {?Object} proto
* @param {?Object=} opt_properties
* @return {!Object}
*/
Object.create = function(proto, opt_properties) {};
/**
* @param {!Object} obj
* @param {?} proto
* @return {!Object}
*/
Object.setPrototypeOf = function(obj, proto) {};
/**
* @param {!Object} obj
* @return {?Object}
* @nosideeffects
*/
Object.getPrototypeOf = function(obj) {};
/**
* @param {!Object} target
* @param {...(Object|null|undefined)} var_args
* @return {!Object}
*/
Object.assign = function(target, var_args) {};
/**
* @param {T} obj
* @return {T}
* @template T
*/
Object.seal = function(obj) {}
""";
private static final String REFLECT_EXTERNS =
"""
/** @const */
var Reflect = {}
/**
* @param {function(new: ?, ...?)} targetConstructorFn
* @param {!Array<?>} argList
* @param {function(new: TARGET, ...?)=} opt_newTargetConstructorFn
* @return {TARGET}
* @template TARGET
* @nosideeffects
*/
Reflect.construct = function(
targetConstructorFn, argList, opt_newTargetConstructorFn) {};
/**
* @param {!Object} target
* @param {?Object} proto
* @return {boolean}
*/
Reflect.setPrototypeOf = function(target, proto) {};
""";
private static final String ARRAY_EXTERNS =
"""
/**
* @interface
* @template KEY1, VALUE1
*/
function IObject() {};
/**
* @record
* @extends IObject<number, VALUE2>
* @template VALUE2
*/
function IArrayLike() {};
/** @type {number} */
IArrayLike.prototype.length;
/**
* @template T
* @record
* @extends {IArrayLike<T>}
* @extends {Iterable<T>}
*/
function ReadonlyArray(var_args) {}
/** @type {number} */ ReadonlyArray.prototype.length;
/**
* @param {?function(this:S, T, number, !Array<T>): ?} callback
* @param {S=} opt_thisobj
* @this {!IArrayLike<T>|string}
* @template T,S
* @return {undefined}
*/
ReadonlyArray.prototype.forEach;
/**
* @param {?function(this:S, T, number, !Array<T>): ?} callback
* @param {S=} opt_thisobj
* @return {!Array<T>}
* @this {!IArrayLike<T>|string}
* @template T,S
*/
ReadonlyArray.prototype.filter;
/**
* @param {...*} var_args
* @return {!Array<?>}
* @this {*}
*/
ReadonlyArray.prototype.concat;
/**
* @param {?number=} begin Zero-based index at which to begin extraction.
* @param {?number=} end Zero-based index at which to end extraction. slice
* extracts up to but not including end.
* @return {!Array<T>}
* @this {!IArrayLike<T>|string}
* @template T
* @nosideeffects
*/
ReadonlyArray.prototype.slice;
/**
* @return {!IteratorIterable<T>}
*/
ReadonlyArray.prototype.values;
/**
* @param {T} searchElement
* @param {number=} fromIndex
* @return {boolean}
* @this {!IArrayLike<T>|string}
* @template T
* @nosideeffects
*/
ReadonlyArray.prototype.includes;
/**
* @template T
* @constructor
* @implements {ReadonlyArray<T>}
* @implements {IArrayLike<T>}
* @implements {Iterable<T>}
* @param {...*} var_args
* @return {!Array<?>}
*/
function Array(var_args) {}
/** @override */
Array.prototype[Symbol.iterator] = function() {};
/** @override @type {number} */ Array.prototype.length;
/**
* @param {*} arr
* @return {boolean}
*/
Array.isArray = function(arr) {};
/**
* @param {string|!IArrayLike<T>|!Iterable<T>} arrayLike
* @param {function(this:S, (string|T), number): R=} mapFn
* @param {S=} thisObj
* @return {!Array<R>}
* @template T,S,R
*/
Array.from = function(arrayLike, mapFn, thisObj) {}
/**
* @param {...T} var_args
* @return {number} The new length of the array.
* @this {!IArrayLike<T>}
* @template T
* @modifies {this}
*/
Array.prototype.push = function(var_args) {};
/**
* @this {!IArrayLike<T>}
* @return {T}
* @template T
*/
Array.prototype.shift = function() {};
/**
* @override
* @param {?function(this:S, T, number, !Array<T>): ?} callback
* @param {S=} opt_thisobj
* @this {!IArrayLike<T>|string}
* @template T,S
* @return {undefined}
*/
Array.prototype.forEach = function(callback, opt_thisobj) {};
/**
* @override
* @param {?function(this:S, T, number, !Array<T>): ?} callback
* @param {S=} opt_thisobj
* @return {!Array<T>}
* @this {!IArrayLike<T>|string}
* @template T,S
*/
Array.prototype.filter = function(callback, opt_thisobj) {};
/**
* @override
* @param {...*} var_args
* @return {!Array<?>}
* @this {*}
*/
Array.prototype.concat = function(var_args) {};
/**
* @override
* @param {?number=} begin Zero-based index at which to begin extraction.
* @param {?number=} end Zero-based index at which to end extraction. slice
* extracts up to but not including end.
* @return {!Array<T>}
* @this {!IArrayLike<T>|string}
* @template T
* @nosideeffects
*/
Array.prototype.slice = function(begin, end) {};
/**
* @override
* @return {!IteratorIterable<T>}
*/
Array.prototype.values;
/**
* @override
* @param {T} searchElement
* @param {number=} fromIndex
* @return {boolean}
* @this {!IArrayLike<T>|string}
* @template T
* @nosideeffects
*/
Array.prototype.includes = function(searchElement, fromIndex) {};
""";
private static final String MAP_EXTERNS =
"""
/**
* @interface
* @extends {Iterable<K|V>}
* @template K, V
*/
function ReadonlyMap() {}
/**
* @return {!IteratorIterable<K|V>}
*/
ReadonlyMap.prototype.entries = function() {};
/**
* @constructor @struct
* @param {?Iterable<!Array<K|V>>|!Array<!Array<K|V>>=} opt_iterable
* @implements {ReadonlyMap<K, V>}
* @template K, V
*/
function Map(opt_iterable) {}
/** @override */
Map.prototype[Symbol.iterator] = function() {};
/**
* @override
* @return {!IteratorIterable<K|V>}
*/
Map.prototype.entries = function() {};\
""";
private static final String ARGUMENTS_EXTERNS =
"""
/**
* @constructor
* @implements {IArrayLike<?>}
* @implements {Iterable<?>}
*/
function Arguments() {}
/** @type {number} */
Arguments.prototype.length;
/** @override */
Arguments.prototype[Symbol.iterator] = function() {};
/** @type {!Arguments} */
var arguments;
""";
private static final String CONSOLE_EXTERNS =
"""
/** @constructor */
function Console() {};
/**
* @param {...*} var_args
* @return {undefined}
*/
Console.prototype.log = function(var_args) {};
/** @const {!Console} */
var console;
""";
private static final String ALERT_EXTERNS =
"""
/**
* @param {*} message
* @return {undefined}
*/
function alert(message) {}
""";
private static final String UNDEFINED_EXTERNS =
"""
/** @type {undefined} */
var undefined;
""";
private static final String PROMISE_EXTERNS =
"""
/**
* @typedef {{then: ?}}
*/
var Thenable;
/**
* @interface
* @template TYPE
*/
function IThenable() {}
/**
* @param {?(function(TYPE):VALUE)=} opt_onFulfilled
* @param {?(function(*): *)=} opt_onRejected
* @return {RESULT}
* @template VALUE
*
* @template RESULT := type('IThenable',
* cond(isUnknown(VALUE), unknown(),
* mapunion(VALUE, (V) =>
* cond(isTemplatized(V) && sub(rawTypeOf(V), 'IThenable'),
* templateTypeOf(V, 0),
* cond(sub(V, 'Thenable'),
* unknown(),
* V)))))
* =:
*/
IThenable.prototype.then = function(opt_onFulfilled, opt_onRejected) {};
/**
* @param {function(
* function((TYPE|IThenable<TYPE>|Thenable|null)=),
* function(*=))} resolver
* @constructor
* @implements {IThenable<TYPE>}
* @template TYPE
*/
function Promise(resolver) {}
/**
* @param {VALUE=} opt_value
* @return {RESULT}
* @template VALUE
* @template RESULT := type('Promise',
* cond(isUnknown(VALUE), unknown(),
* mapunion(VALUE, (V) =>
* cond(isTemplatized(V) && sub(rawTypeOf(V), 'IThenable'),
* templateTypeOf(V, 0),
* cond(sub(V, 'Thenable'),
* unknown(),
* V)))))
* =:
*/
Promise.resolve = function(opt_value) {};
/**
* @param {*=} opt_error
* @return {!Promise<?>}
*/
Promise.reject = function(opt_error) {};
/**
* @param {!Iterable<VALUE>} iterable
* @return {!Promise<!Array<RESULT>>}
* @template VALUE
* @template RESULT := mapunion(VALUE, (V) =>
* cond(isUnknown(V),
* unknown(),
* cond(isTemplatized(V) && sub(rawTypeOf(V), 'IThenable'),
* templateTypeOf(V, 0),
* cond(sub(V, 'Thenable'), unknown(), V))))
* =:
*/
Promise.all = function(iterable) {};
/**
* @param {!Iterable<VALUE>} iterable
* @return {!Promise<RESULT>}
* @template VALUE
* @template RESULT := mapunion(VALUE, (V) =>
* cond(isUnknown(V),
* unknown(),
* cond(isTemplatized(V) && sub(rawTypeOf(V), 'IThenable'),
* templateTypeOf(V, 0),
* cond(sub(V, 'Thenable'), unknown(), V))))
* =:
*/
Promise.race = function(iterable) {};
/**
* @param {?(function(this:void, TYPE):VALUE)=} opt_onFulfilled
* @param {?(function(this:void, *): *)=} opt_onRejected
* @return {RESULT}
* @template VALUE
*
* @template RESULT := type('Promise',
* cond(isUnknown(VALUE), unknown(),
* mapunion(VALUE, (V) =>
* cond(isTemplatized(V) && sub(rawTypeOf(V), 'IThenable'),
* templateTypeOf(V, 0),
* cond(sub(V, 'Thenable'),
* unknown(),
* V)))))
* =:
* @override
*/
Promise.prototype.then = function(opt_onFulfilled, opt_onRejected) {};
/**
* @param {function(*): RESULT} onRejected
* @return {!Promise<RESULT>}
* @template RESULT
*/
Promise.prototype.catch = function(onRejected) {};
/**
* @param {function()} callback
* @return {!Promise<TYPE>}
*/
Promise.prototype.finally = function(callback) {};
""";
private static final String I_TEMPLATE_ARRAY_EXTERNS =
"""
/**
* @constructor
* @extends {Array<string>}
*/
function ITemplateArray() {}\
""";
private static final String ASYNC_ITERABLE_EXTERNS =
"""
/**
* @const {symbol}
*/
Symbol.asyncIterator;
/**
* @interface
* @template T, TReturn, TNext
*/
function AsyncIterator() {}
/**
* @param {?=} opt_value
* @return {!Promise<!IIterableResult<T>>}
*/
AsyncIterator.prototype.next;
/**
* @interface
* @template T, TReturn, TNext
*/
function AsyncIterable() {}
/**
* @return {!AsyncIterator<T,?,*>}
*/
AsyncIterable.prototype[Symbol.asyncIterator] = function() {};
/**
* @interface
* @extends {AsyncIterator<T,?,*>}
* @extends {AsyncIterable<T,?,*>}
* @template T, TReturn, TNext
*/
function AsyncIteratorIterable() {}
/**
* @interface
* @extends {AsyncIteratorIterable<T,?,*>}
* @template T, TReturn, TNext
*/
function AsyncGenerator() {}
/**
* @param {?=} opt_value
* @return {!Promise<!IIterableResult<T>>}
* @override
*/
AsyncGenerator.prototype.next = function(opt_value) {};
/**
* @param {T} value
* @return {!Promise<!IIterableResult<T>>}
*/
AsyncGenerator.prototype.return = function(value) {};
/**
* @param {?} exception
* @return {!Promise<!IIterableResult<T>>}
*/
AsyncGenerator.prototype.throw = function(exception) {};\
""";
// Test cases that perform transpilation of ES6 classes but use a non-injecting compiler need
// these definitions.
private static final String ES6_CLASS_TRANSPILATION_EXTERNS =
"""
var $jscomp = {};
/**
* @param {?} subClass
* @param {?} superClass
* @return {?} newClass
*/
$jscomp.inherits = function(subClass, superClass) {};
""";
private static final String MATH_EXTERNS =
"""
/** @const */
var Math = {};
/**
* @return {number}
* @nosideeffects
*/
Math.random = function() {};
/**
* @param {number} a
* @param {number} b
* @return {number}
* @nosideeffects
*/
Math.max = function(a, b) {};
/**
* @param {number} a
* @param {number} b
* @return {number}
* @nosideeffects
*/
Math.min = function(a, b) {};
/**
* @param {number} a
* @param {number} b
* @return {number}
* @nosideeffects
*/
Math.pow = function(a, b) {};
""";
private static final String REG_EXP_EXTERNS =
"""
/**
* @constructor
* @param {*=} opt_pattern
* @param {*=} opt_flags
* @return {!RegExp}
* @throws {SyntaxError} if opt_pattern is an invalid pattern.
*/
function RegExp(opt_pattern, opt_flags) {}
/**
* @param {*} str The string to search.
* @return {?RegExpResult}
*/
RegExp.prototype.exec = function(str) {};
/**
* @constructor
* @extends {Array<string>}
*/
var RegExpResult = function() {};
/** @type {string} */
RegExp.$1;\
""";
private static final String HTML_ELEMENT_EXTERNS =
"""
/** @constructor */
function Node() {}
/** @constructor @extends {Node} */
function Element() {}
/** @constructor @extends {Element} */
function HTMLElement() {}\
""";
private static final String POLYMER_EXTERNS =
"""
/**
* @param {!Object} init
* @return {!function(new:HTMLElement)}
*/
function Polymer(init) {}
Polymer.ElementMixin = function(mixin) {}
/** @typedef {!Object} */
var PolymerElementProperties;
/** @interface */
function Polymer_ElementMixin() {}
/** @type {string} */
Polymer_ElementMixin.prototype._importPath;
/**
* @interface
* @extends {Polymer_ElementMixin}
*/
function Polymer_LegacyElementMixin(){}
/** @type {boolean} */
Polymer_LegacyElementMixin.prototype.isAttached;
/**
* @constructor
* @extends {HTMLElement}
* @implements {Polymer_LegacyElementMixin}
*/
var PolymerElement = function() {}; // Polymer 1
/** @constructor @extends {HTMLElement} */
Polymer.Element = function() {}; // Polymer 2
""";
private boolean includeBigIntExterns = false;
private boolean includeIterableExterns = false;
private boolean includeStringExterns = false;
private boolean includeFunctionExterns = false;
private boolean includeObjectExterns = false;
private boolean includeArrayExterns = false;
private boolean includeMapExterns = false;
private boolean includeArgumentsExterns = false;
private boolean includeUndefinedExterns = false;
private boolean includeITemplateArrayExterns = false;
private boolean includeConsoleExterns = false;
private boolean includeAlertExterns = false;
private boolean includePromiseExterns = false;
private boolean includeAsyncIterableExterns = false;
private boolean includeEs6ClassTranspilationExterns = false;
private boolean includeReflectExterns = false;
private boolean includeClosureExterns = false;
private boolean includeJSCompLibraries = false;
private boolean includeMathExterns = false;
private boolean includeRegExpExterns = false;
private boolean includeHtmlElementExterns = false;
private boolean includePolymerExterns = false;
private final List<String> extraExterns = new ArrayList<>();
@CanIgnoreReturnValue
public TestExternsBuilder addBigInt() {
includeBigIntExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addIterable() {
includeIterableExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addString() {
includeStringExterns = true;
addIterable(); // String implements Iterable<string>
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addFunction() {
includeFunctionExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addObject() {
includeObjectExterns = true;
addFunction(); // Object.prototype.constructor has type {?Function}
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addArray() {
includeArrayExterns = true;
addIterable(); // Array implements Iterable
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addMap() {
includeMapExterns = true;
addArray(); // Map requires array for its ctor arg.
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addArguments() {
includeArgumentsExterns = true;
addArray(); // Arguments implements IArrayLike
addIterable(); // Arguments implements Iterable
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addUndefined() {
includeUndefinedExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addITemplateArray() {
includeITemplateArrayExterns = true;
addArray(); // ITemplateArray extends Array
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addPromise() {
includePromiseExterns = true;
addIterable(); // Promise.all() and Promise.race() need Iterable
return this;
}
/** Adds declaration of `console.log()` */
@CanIgnoreReturnValue
public TestExternsBuilder addConsole() {
includeConsoleExterns = true;
return this;
}
/** Adds declaration of `alert(message)` */
@CanIgnoreReturnValue
public TestExternsBuilder addAlert() {
includeAlertExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addAsyncIterable() {
includeAsyncIterableExterns = true;
addIterable(); // IIterableResult + Symbol
addPromise(); // Promise
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addReflect() {
includeReflectExterns = true;
addObject(); // Reflect shares many things in common with Object
return this;
}
/**
* Externs needed for successful transpilation of ES6 classes without injecting the runtime code.
*
* <p>ES6 class transpilation depends on some runtime code that we often don't want to actually
* generate in test cases, so we use a non-injecting compiler and include these externs
* definitions to keep the type checker happy.
*/
@CanIgnoreReturnValue
public TestExternsBuilder addEs6ClassTranspilationExterns() {
includeEs6ClassTranspilationExterns = true;
addFunction(); // need definition of Function.prototype.apply
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addClosureExterns() {
includeClosureExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addJSCompLibraries() {
includeJSCompLibraries = true;
addArguments(); // need definition of Arguments
addIterable(); // need definition of Iterable and Array
addReflect(); // need Reflect.construct
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addMath() {
includeMathExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addRegExp() {
addArray(); // RegExpResult needs definition of Array
includeRegExpExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addHtmlElement() {
includeHtmlElementExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addPolymer() {
addHtmlElement();
includePolymerExterns = true;
return this;
}
@CanIgnoreReturnValue
public TestExternsBuilder addExtra(String... lines) {
Collections.addAll(extraExterns, lines);
return this;
}
public String build() {
List<String> externSections = new ArrayList<>();
externSections.add(
"""
/**
* @fileoverview
* @externs
*/
""");
if (includeBigIntExterns) {
externSections.add(BIGINT_EXTERNS);
}
if (includeIterableExterns) {
externSections.add(ITERABLE_EXTERNS);
}
if (includeStringExterns) {
externSections.add(STRING_EXTERNS);
}
if (includeFunctionExterns) {
externSections.add(FUNCTION_EXTERNS);
}
if (includeObjectExterns) {
externSections.add(OBJECT_EXTERNS);
}
if (includeArrayExterns) {
externSections.add(ARRAY_EXTERNS);
}
if (includeMapExterns) {
externSections.add(MAP_EXTERNS);
}
if (includeReflectExterns) {
externSections.add(REFLECT_EXTERNS);
}
if (includeArgumentsExterns) {
externSections.add(ARGUMENTS_EXTERNS);
}
if (includeUndefinedExterns) {
externSections.add(UNDEFINED_EXTERNS);
}
if (includeITemplateArrayExterns) {
externSections.add(I_TEMPLATE_ARRAY_EXTERNS);
}
if (includeConsoleExterns) {
externSections.add(CONSOLE_EXTERNS);
}
if (includeAlertExterns) {
externSections.add(ALERT_EXTERNS);
}
if (includePromiseExterns) {
externSections.add(PROMISE_EXTERNS);
}
if (includeAsyncIterableExterns) {
externSections.add(ASYNC_ITERABLE_EXTERNS);
}
if (includeMathExterns) {
externSections.add(MATH_EXTERNS);
}
if (includeRegExpExterns) {
externSections.add(REG_EXP_EXTERNS);
}
if (includeEs6ClassTranspilationExterns) {
externSections.add(ES6_CLASS_TRANSPILATION_EXTERNS);
}
if (includeClosureExterns) {
externSections.add(CLOSURE_EXTERNS);
}
if (includeJSCompLibraries) {
externSections.add(JSCOMP_LIBRARIES);
}
if (includeHtmlElementExterns) {
externSections.add(HTML_ELEMENT_EXTERNS);
}
if (includePolymerExterns) {
externSections.add(POLYMER_EXTERNS);
}
externSections.addAll(extraExterns);
return Joiner.on('\n').join(externSections);
}
public SourceFile buildExternsFile(String filePath) {
String externsString = build();
return SourceFile.fromCode(filePath, externsString);
}
}
|
googleads/google-ads-java | 36,424 | google-ads-stubs-v19/src/main/java/com/google/ads/googleads/v19/services/SuggestTravelAssetsRequest.java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/ads/googleads/v19/services/travel_asset_suggestion_service.proto
// Protobuf Java Version: 3.25.7
package com.google.ads.googleads.v19.services;
/**
* <pre>
* Request message for
* [TravelAssetSuggestionService.SuggestTravelAssets][google.ads.googleads.v19.services.TravelAssetSuggestionService.SuggestTravelAssets].
* </pre>
*
* Protobuf type {@code google.ads.googleads.v19.services.SuggestTravelAssetsRequest}
*/
public final class SuggestTravelAssetsRequest extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:google.ads.googleads.v19.services.SuggestTravelAssetsRequest)
SuggestTravelAssetsRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use SuggestTravelAssetsRequest.newBuilder() to construct.
private SuggestTravelAssetsRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SuggestTravelAssetsRequest() {
customerId_ = "";
languageOption_ = "";
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new SuggestTravelAssetsRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v19.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v19_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v19.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v19_services_SuggestTravelAssetsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest.class, com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest.Builder.class);
}
public static final int CUSTOMER_ID_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object customerId_ = "";
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The customerId.
*/
@java.lang.Override
public java.lang.String getCustomerId() {
java.lang.Object ref = customerId_;
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();
customerId_ = s;
return s;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for customerId.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getCustomerIdBytes() {
java.lang.Object ref = customerId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
customerId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int LANGUAGE_OPTION_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object languageOption_ = "";
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The languageOption.
*/
@java.lang.Override
public java.lang.String getLanguageOption() {
java.lang.Object ref = languageOption_;
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();
languageOption_ = s;
return s;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for languageOption.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getLanguageOptionBytes() {
java.lang.Object ref = languageOption_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
languageOption_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PLACE_IDS_FIELD_NUMBER = 4;
@SuppressWarnings("serial")
private com.google.protobuf.LazyStringArrayList placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return A list containing the placeIds.
*/
public com.google.protobuf.ProtocolStringList
getPlaceIdsList() {
return placeIds_;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return The count of placeIds.
*/
public int getPlaceIdsCount() {
return placeIds_.size();
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the element to return.
* @return The placeIds at the given index.
*/
public java.lang.String getPlaceIds(int index) {
return placeIds_.get(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the value to return.
* @return The bytes of the placeIds at the given index.
*/
public com.google.protobuf.ByteString
getPlaceIdsBytes(int index) {
return placeIds_.getByteString(index);
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(customerId_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, customerId_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageOption_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, languageOption_);
}
for (int i = 0; i < placeIds_.size(); i++) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, placeIds_.getRaw(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(customerId_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, customerId_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageOption_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, languageOption_);
}
{
int dataSize = 0;
for (int i = 0; i < placeIds_.size(); i++) {
dataSize += computeStringSizeNoTag(placeIds_.getRaw(i));
}
size += dataSize;
size += 1 * getPlaceIdsList().size();
}
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.ads.googleads.v19.services.SuggestTravelAssetsRequest)) {
return super.equals(obj);
}
com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest other = (com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest) obj;
if (!getCustomerId()
.equals(other.getCustomerId())) return false;
if (!getLanguageOption()
.equals(other.getLanguageOption())) return false;
if (!getPlaceIdsList()
.equals(other.getPlaceIdsList())) 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();
hash = (37 * hash) + CUSTOMER_ID_FIELD_NUMBER;
hash = (53 * hash) + getCustomerId().hashCode();
hash = (37 * hash) + LANGUAGE_OPTION_FIELD_NUMBER;
hash = (53 * hash) + getLanguageOption().hashCode();
if (getPlaceIdsCount() > 0) {
hash = (37 * hash) + PLACE_IDS_FIELD_NUMBER;
hash = (53 * hash) + getPlaceIdsList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest 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.ads.googleads.v19.services.SuggestTravelAssetsRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest 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.ads.googleads.v19.services.SuggestTravelAssetsRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest 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.ads.googleads.v19.services.SuggestTravelAssetsRequest parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest 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.ads.googleads.v19.services.SuggestTravelAssetsRequest 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;
}
/**
* <pre>
* Request message for
* [TravelAssetSuggestionService.SuggestTravelAssets][google.ads.googleads.v19.services.TravelAssetSuggestionService.SuggestTravelAssets].
* </pre>
*
* Protobuf type {@code google.ads.googleads.v19.services.SuggestTravelAssetsRequest}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:google.ads.googleads.v19.services.SuggestTravelAssetsRequest)
com.google.ads.googleads.v19.services.SuggestTravelAssetsRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v19.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v19_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v19.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v19_services_SuggestTravelAssetsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest.class, com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest.Builder.class);
}
// Construct using com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest.newBuilder()
private Builder() {
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
customerId_ = "";
languageOption_ = "";
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return com.google.ads.googleads.v19.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v19_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
public com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest getDefaultInstanceForType() {
return com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest build() {
com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest buildPartial() {
com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest result = new com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest(this);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartial0(com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.customerId_ = customerId_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.languageOption_ = languageOption_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
placeIds_.makeImmutable();
result.placeIds_ = placeIds_;
}
}
@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.ads.googleads.v19.services.SuggestTravelAssetsRequest) {
return mergeFrom((com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest other) {
if (other == com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest.getDefaultInstance()) return this;
if (!other.getCustomerId().isEmpty()) {
customerId_ = other.customerId_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getLanguageOption().isEmpty()) {
languageOption_ = other.languageOption_;
bitField0_ |= 0x00000002;
onChanged();
}
if (!other.placeIds_.isEmpty()) {
if (placeIds_.isEmpty()) {
placeIds_ = other.placeIds_;
bitField0_ |= 0x00000004;
} else {
ensurePlaceIdsIsMutable();
placeIds_.addAll(other.placeIds_);
}
onChanged();
}
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 10: {
customerId_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18: {
languageOption_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 34: {
java.lang.String s = input.readStringRequireUtf8();
ensurePlaceIdsIsMutable();
placeIds_.add(s);
break;
} // case 34
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.lang.Object customerId_ = "";
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The customerId.
*/
public java.lang.String getCustomerId() {
java.lang.Object ref = customerId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
customerId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for customerId.
*/
public com.google.protobuf.ByteString
getCustomerIdBytes() {
java.lang.Object ref = customerId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
customerId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The customerId to set.
* @return This builder for chaining.
*/
public Builder setCustomerId(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
customerId_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return This builder for chaining.
*/
public Builder clearCustomerId() {
customerId_ = getDefaultInstance().getCustomerId();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The bytes for customerId to set.
* @return This builder for chaining.
*/
public Builder setCustomerIdBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
customerId_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object languageOption_ = "";
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The languageOption.
*/
public java.lang.String getLanguageOption() {
java.lang.Object ref = languageOption_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
languageOption_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for languageOption.
*/
public com.google.protobuf.ByteString
getLanguageOptionBytes() {
java.lang.Object ref = languageOption_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
languageOption_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The languageOption to set.
* @return This builder for chaining.
*/
public Builder setLanguageOption(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
languageOption_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return This builder for chaining.
*/
public Builder clearLanguageOption() {
languageOption_ = getDefaultInstance().getLanguageOption();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The bytes for languageOption to set.
* @return This builder for chaining.
*/
public Builder setLanguageOptionBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
languageOption_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private com.google.protobuf.LazyStringArrayList placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
private void ensurePlaceIdsIsMutable() {
if (!placeIds_.isModifiable()) {
placeIds_ = new com.google.protobuf.LazyStringArrayList(placeIds_);
}
bitField0_ |= 0x00000004;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return A list containing the placeIds.
*/
public com.google.protobuf.ProtocolStringList
getPlaceIdsList() {
placeIds_.makeImmutable();
return placeIds_;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return The count of placeIds.
*/
public int getPlaceIdsCount() {
return placeIds_.size();
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the element to return.
* @return The placeIds at the given index.
*/
public java.lang.String getPlaceIds(int index) {
return placeIds_.get(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the value to return.
* @return The bytes of the placeIds at the given index.
*/
public com.google.protobuf.ByteString
getPlaceIdsBytes(int index) {
return placeIds_.getByteString(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index to set the value at.
* @param value The placeIds to set.
* @return This builder for chaining.
*/
public Builder setPlaceIds(
int index, java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
ensurePlaceIdsIsMutable();
placeIds_.set(index, value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param value The placeIds to add.
* @return This builder for chaining.
*/
public Builder addPlaceIds(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
ensurePlaceIdsIsMutable();
placeIds_.add(value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param values The placeIds to add.
* @return This builder for chaining.
*/
public Builder addAllPlaceIds(
java.lang.Iterable<java.lang.String> values) {
ensurePlaceIdsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
values, placeIds_);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return This builder for chaining.
*/
public Builder clearPlaceIds() {
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
bitField0_ = (bitField0_ & ~0x00000004);;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param value The bytes of the placeIds to add.
* @return This builder for chaining.
*/
public Builder addPlaceIdsBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
ensurePlaceIdsIsMutable();
placeIds_.add(value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
@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.ads.googleads.v19.services.SuggestTravelAssetsRequest)
}
// @@protoc_insertion_point(class_scope:google.ads.googleads.v19.services.SuggestTravelAssetsRequest)
private static final com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest();
}
public static com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<SuggestTravelAssetsRequest>
PARSER = new com.google.protobuf.AbstractParser<SuggestTravelAssetsRequest>() {
@java.lang.Override
public SuggestTravelAssetsRequest 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<SuggestTravelAssetsRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SuggestTravelAssetsRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.ads.googleads.v19.services.SuggestTravelAssetsRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleads/google-ads-java | 36,424 | google-ads-stubs-v20/src/main/java/com/google/ads/googleads/v20/services/SuggestTravelAssetsRequest.java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/ads/googleads/v20/services/travel_asset_suggestion_service.proto
// Protobuf Java Version: 3.25.7
package com.google.ads.googleads.v20.services;
/**
* <pre>
* Request message for
* [TravelAssetSuggestionService.SuggestTravelAssets][google.ads.googleads.v20.services.TravelAssetSuggestionService.SuggestTravelAssets].
* </pre>
*
* Protobuf type {@code google.ads.googleads.v20.services.SuggestTravelAssetsRequest}
*/
public final class SuggestTravelAssetsRequest extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:google.ads.googleads.v20.services.SuggestTravelAssetsRequest)
SuggestTravelAssetsRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use SuggestTravelAssetsRequest.newBuilder() to construct.
private SuggestTravelAssetsRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SuggestTravelAssetsRequest() {
customerId_ = "";
languageOption_ = "";
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new SuggestTravelAssetsRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v20.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v20_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v20.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v20_services_SuggestTravelAssetsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest.class, com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest.Builder.class);
}
public static final int CUSTOMER_ID_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object customerId_ = "";
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The customerId.
*/
@java.lang.Override
public java.lang.String getCustomerId() {
java.lang.Object ref = customerId_;
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();
customerId_ = s;
return s;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for customerId.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getCustomerIdBytes() {
java.lang.Object ref = customerId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
customerId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int LANGUAGE_OPTION_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object languageOption_ = "";
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The languageOption.
*/
@java.lang.Override
public java.lang.String getLanguageOption() {
java.lang.Object ref = languageOption_;
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();
languageOption_ = s;
return s;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for languageOption.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getLanguageOptionBytes() {
java.lang.Object ref = languageOption_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
languageOption_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PLACE_IDS_FIELD_NUMBER = 4;
@SuppressWarnings("serial")
private com.google.protobuf.LazyStringArrayList placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return A list containing the placeIds.
*/
public com.google.protobuf.ProtocolStringList
getPlaceIdsList() {
return placeIds_;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return The count of placeIds.
*/
public int getPlaceIdsCount() {
return placeIds_.size();
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the element to return.
* @return The placeIds at the given index.
*/
public java.lang.String getPlaceIds(int index) {
return placeIds_.get(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the value to return.
* @return The bytes of the placeIds at the given index.
*/
public com.google.protobuf.ByteString
getPlaceIdsBytes(int index) {
return placeIds_.getByteString(index);
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(customerId_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, customerId_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageOption_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, languageOption_);
}
for (int i = 0; i < placeIds_.size(); i++) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, placeIds_.getRaw(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(customerId_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, customerId_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageOption_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, languageOption_);
}
{
int dataSize = 0;
for (int i = 0; i < placeIds_.size(); i++) {
dataSize += computeStringSizeNoTag(placeIds_.getRaw(i));
}
size += dataSize;
size += 1 * getPlaceIdsList().size();
}
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.ads.googleads.v20.services.SuggestTravelAssetsRequest)) {
return super.equals(obj);
}
com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest other = (com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest) obj;
if (!getCustomerId()
.equals(other.getCustomerId())) return false;
if (!getLanguageOption()
.equals(other.getLanguageOption())) return false;
if (!getPlaceIdsList()
.equals(other.getPlaceIdsList())) 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();
hash = (37 * hash) + CUSTOMER_ID_FIELD_NUMBER;
hash = (53 * hash) + getCustomerId().hashCode();
hash = (37 * hash) + LANGUAGE_OPTION_FIELD_NUMBER;
hash = (53 * hash) + getLanguageOption().hashCode();
if (getPlaceIdsCount() > 0) {
hash = (37 * hash) + PLACE_IDS_FIELD_NUMBER;
hash = (53 * hash) + getPlaceIdsList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest 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.ads.googleads.v20.services.SuggestTravelAssetsRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest 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.ads.googleads.v20.services.SuggestTravelAssetsRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest 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.ads.googleads.v20.services.SuggestTravelAssetsRequest parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest 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.ads.googleads.v20.services.SuggestTravelAssetsRequest 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;
}
/**
* <pre>
* Request message for
* [TravelAssetSuggestionService.SuggestTravelAssets][google.ads.googleads.v20.services.TravelAssetSuggestionService.SuggestTravelAssets].
* </pre>
*
* Protobuf type {@code google.ads.googleads.v20.services.SuggestTravelAssetsRequest}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:google.ads.googleads.v20.services.SuggestTravelAssetsRequest)
com.google.ads.googleads.v20.services.SuggestTravelAssetsRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v20.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v20_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v20.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v20_services_SuggestTravelAssetsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest.class, com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest.Builder.class);
}
// Construct using com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest.newBuilder()
private Builder() {
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
customerId_ = "";
languageOption_ = "";
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return com.google.ads.googleads.v20.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v20_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
public com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest getDefaultInstanceForType() {
return com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest build() {
com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest buildPartial() {
com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest result = new com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest(this);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartial0(com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.customerId_ = customerId_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.languageOption_ = languageOption_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
placeIds_.makeImmutable();
result.placeIds_ = placeIds_;
}
}
@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.ads.googleads.v20.services.SuggestTravelAssetsRequest) {
return mergeFrom((com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest other) {
if (other == com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest.getDefaultInstance()) return this;
if (!other.getCustomerId().isEmpty()) {
customerId_ = other.customerId_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getLanguageOption().isEmpty()) {
languageOption_ = other.languageOption_;
bitField0_ |= 0x00000002;
onChanged();
}
if (!other.placeIds_.isEmpty()) {
if (placeIds_.isEmpty()) {
placeIds_ = other.placeIds_;
bitField0_ |= 0x00000004;
} else {
ensurePlaceIdsIsMutable();
placeIds_.addAll(other.placeIds_);
}
onChanged();
}
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 10: {
customerId_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18: {
languageOption_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 34: {
java.lang.String s = input.readStringRequireUtf8();
ensurePlaceIdsIsMutable();
placeIds_.add(s);
break;
} // case 34
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.lang.Object customerId_ = "";
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The customerId.
*/
public java.lang.String getCustomerId() {
java.lang.Object ref = customerId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
customerId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for customerId.
*/
public com.google.protobuf.ByteString
getCustomerIdBytes() {
java.lang.Object ref = customerId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
customerId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The customerId to set.
* @return This builder for chaining.
*/
public Builder setCustomerId(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
customerId_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return This builder for chaining.
*/
public Builder clearCustomerId() {
customerId_ = getDefaultInstance().getCustomerId();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The bytes for customerId to set.
* @return This builder for chaining.
*/
public Builder setCustomerIdBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
customerId_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object languageOption_ = "";
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The languageOption.
*/
public java.lang.String getLanguageOption() {
java.lang.Object ref = languageOption_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
languageOption_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for languageOption.
*/
public com.google.protobuf.ByteString
getLanguageOptionBytes() {
java.lang.Object ref = languageOption_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
languageOption_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The languageOption to set.
* @return This builder for chaining.
*/
public Builder setLanguageOption(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
languageOption_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return This builder for chaining.
*/
public Builder clearLanguageOption() {
languageOption_ = getDefaultInstance().getLanguageOption();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The bytes for languageOption to set.
* @return This builder for chaining.
*/
public Builder setLanguageOptionBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
languageOption_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private com.google.protobuf.LazyStringArrayList placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
private void ensurePlaceIdsIsMutable() {
if (!placeIds_.isModifiable()) {
placeIds_ = new com.google.protobuf.LazyStringArrayList(placeIds_);
}
bitField0_ |= 0x00000004;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return A list containing the placeIds.
*/
public com.google.protobuf.ProtocolStringList
getPlaceIdsList() {
placeIds_.makeImmutable();
return placeIds_;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return The count of placeIds.
*/
public int getPlaceIdsCount() {
return placeIds_.size();
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the element to return.
* @return The placeIds at the given index.
*/
public java.lang.String getPlaceIds(int index) {
return placeIds_.get(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the value to return.
* @return The bytes of the placeIds at the given index.
*/
public com.google.protobuf.ByteString
getPlaceIdsBytes(int index) {
return placeIds_.getByteString(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index to set the value at.
* @param value The placeIds to set.
* @return This builder for chaining.
*/
public Builder setPlaceIds(
int index, java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
ensurePlaceIdsIsMutable();
placeIds_.set(index, value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param value The placeIds to add.
* @return This builder for chaining.
*/
public Builder addPlaceIds(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
ensurePlaceIdsIsMutable();
placeIds_.add(value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param values The placeIds to add.
* @return This builder for chaining.
*/
public Builder addAllPlaceIds(
java.lang.Iterable<java.lang.String> values) {
ensurePlaceIdsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
values, placeIds_);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return This builder for chaining.
*/
public Builder clearPlaceIds() {
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
bitField0_ = (bitField0_ & ~0x00000004);;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param value The bytes of the placeIds to add.
* @return This builder for chaining.
*/
public Builder addPlaceIdsBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
ensurePlaceIdsIsMutable();
placeIds_.add(value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
@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.ads.googleads.v20.services.SuggestTravelAssetsRequest)
}
// @@protoc_insertion_point(class_scope:google.ads.googleads.v20.services.SuggestTravelAssetsRequest)
private static final com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest();
}
public static com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<SuggestTravelAssetsRequest>
PARSER = new com.google.protobuf.AbstractParser<SuggestTravelAssetsRequest>() {
@java.lang.Override
public SuggestTravelAssetsRequest 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<SuggestTravelAssetsRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SuggestTravelAssetsRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.ads.googleads.v20.services.SuggestTravelAssetsRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleads/google-ads-java | 36,424 | google-ads-stubs-v21/src/main/java/com/google/ads/googleads/v21/services/SuggestTravelAssetsRequest.java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/ads/googleads/v21/services/travel_asset_suggestion_service.proto
// Protobuf Java Version: 3.25.7
package com.google.ads.googleads.v21.services;
/**
* <pre>
* Request message for
* [TravelAssetSuggestionService.SuggestTravelAssets][google.ads.googleads.v21.services.TravelAssetSuggestionService.SuggestTravelAssets].
* </pre>
*
* Protobuf type {@code google.ads.googleads.v21.services.SuggestTravelAssetsRequest}
*/
public final class SuggestTravelAssetsRequest extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:google.ads.googleads.v21.services.SuggestTravelAssetsRequest)
SuggestTravelAssetsRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use SuggestTravelAssetsRequest.newBuilder() to construct.
private SuggestTravelAssetsRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SuggestTravelAssetsRequest() {
customerId_ = "";
languageOption_ = "";
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new SuggestTravelAssetsRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v21.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v21_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v21.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v21_services_SuggestTravelAssetsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest.class, com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest.Builder.class);
}
public static final int CUSTOMER_ID_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object customerId_ = "";
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The customerId.
*/
@java.lang.Override
public java.lang.String getCustomerId() {
java.lang.Object ref = customerId_;
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();
customerId_ = s;
return s;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for customerId.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getCustomerIdBytes() {
java.lang.Object ref = customerId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
customerId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int LANGUAGE_OPTION_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object languageOption_ = "";
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The languageOption.
*/
@java.lang.Override
public java.lang.String getLanguageOption() {
java.lang.Object ref = languageOption_;
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();
languageOption_ = s;
return s;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for languageOption.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getLanguageOptionBytes() {
java.lang.Object ref = languageOption_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
languageOption_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PLACE_IDS_FIELD_NUMBER = 4;
@SuppressWarnings("serial")
private com.google.protobuf.LazyStringArrayList placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return A list containing the placeIds.
*/
public com.google.protobuf.ProtocolStringList
getPlaceIdsList() {
return placeIds_;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return The count of placeIds.
*/
public int getPlaceIdsCount() {
return placeIds_.size();
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the element to return.
* @return The placeIds at the given index.
*/
public java.lang.String getPlaceIds(int index) {
return placeIds_.get(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the value to return.
* @return The bytes of the placeIds at the given index.
*/
public com.google.protobuf.ByteString
getPlaceIdsBytes(int index) {
return placeIds_.getByteString(index);
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(customerId_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, customerId_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageOption_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, languageOption_);
}
for (int i = 0; i < placeIds_.size(); i++) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, placeIds_.getRaw(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(customerId_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, customerId_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(languageOption_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, languageOption_);
}
{
int dataSize = 0;
for (int i = 0; i < placeIds_.size(); i++) {
dataSize += computeStringSizeNoTag(placeIds_.getRaw(i));
}
size += dataSize;
size += 1 * getPlaceIdsList().size();
}
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.ads.googleads.v21.services.SuggestTravelAssetsRequest)) {
return super.equals(obj);
}
com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest other = (com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest) obj;
if (!getCustomerId()
.equals(other.getCustomerId())) return false;
if (!getLanguageOption()
.equals(other.getLanguageOption())) return false;
if (!getPlaceIdsList()
.equals(other.getPlaceIdsList())) 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();
hash = (37 * hash) + CUSTOMER_ID_FIELD_NUMBER;
hash = (53 * hash) + getCustomerId().hashCode();
hash = (37 * hash) + LANGUAGE_OPTION_FIELD_NUMBER;
hash = (53 * hash) + getLanguageOption().hashCode();
if (getPlaceIdsCount() > 0) {
hash = (37 * hash) + PLACE_IDS_FIELD_NUMBER;
hash = (53 * hash) + getPlaceIdsList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest 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.ads.googleads.v21.services.SuggestTravelAssetsRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest 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.ads.googleads.v21.services.SuggestTravelAssetsRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest 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.ads.googleads.v21.services.SuggestTravelAssetsRequest parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest 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.ads.googleads.v21.services.SuggestTravelAssetsRequest 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;
}
/**
* <pre>
* Request message for
* [TravelAssetSuggestionService.SuggestTravelAssets][google.ads.googleads.v21.services.TravelAssetSuggestionService.SuggestTravelAssets].
* </pre>
*
* Protobuf type {@code google.ads.googleads.v21.services.SuggestTravelAssetsRequest}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:google.ads.googleads.v21.services.SuggestTravelAssetsRequest)
com.google.ads.googleads.v21.services.SuggestTravelAssetsRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.google.ads.googleads.v21.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v21_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.ads.googleads.v21.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v21_services_SuggestTravelAssetsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest.class, com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest.Builder.class);
}
// Construct using com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest.newBuilder()
private Builder() {
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
customerId_ = "";
languageOption_ = "";
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return com.google.ads.googleads.v21.services.TravelAssetSuggestionServiceProto.internal_static_google_ads_googleads_v21_services_SuggestTravelAssetsRequest_descriptor;
}
@java.lang.Override
public com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest getDefaultInstanceForType() {
return com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest build() {
com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest buildPartial() {
com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest result = new com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest(this);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartial0(com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.customerId_ = customerId_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.languageOption_ = languageOption_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
placeIds_.makeImmutable();
result.placeIds_ = placeIds_;
}
}
@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.ads.googleads.v21.services.SuggestTravelAssetsRequest) {
return mergeFrom((com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest other) {
if (other == com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest.getDefaultInstance()) return this;
if (!other.getCustomerId().isEmpty()) {
customerId_ = other.customerId_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getLanguageOption().isEmpty()) {
languageOption_ = other.languageOption_;
bitField0_ |= 0x00000002;
onChanged();
}
if (!other.placeIds_.isEmpty()) {
if (placeIds_.isEmpty()) {
placeIds_ = other.placeIds_;
bitField0_ |= 0x00000004;
} else {
ensurePlaceIdsIsMutable();
placeIds_.addAll(other.placeIds_);
}
onChanged();
}
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 10: {
customerId_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18: {
languageOption_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 34: {
java.lang.String s = input.readStringRequireUtf8();
ensurePlaceIdsIsMutable();
placeIds_.add(s);
break;
} // case 34
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.lang.Object customerId_ = "";
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The customerId.
*/
public java.lang.String getCustomerId() {
java.lang.Object ref = customerId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
customerId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for customerId.
*/
public com.google.protobuf.ByteString
getCustomerIdBytes() {
java.lang.Object ref = customerId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
customerId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The customerId to set.
* @return This builder for chaining.
*/
public Builder setCustomerId(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
customerId_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @return This builder for chaining.
*/
public Builder clearCustomerId() {
customerId_ = getDefaultInstance().getCustomerId();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
* <pre>
* Required. The ID of the customer.
* </pre>
*
* <code>string customer_id = 1 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The bytes for customerId to set.
* @return This builder for chaining.
*/
public Builder setCustomerIdBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
customerId_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object languageOption_ = "";
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The languageOption.
*/
public java.lang.String getLanguageOption() {
java.lang.Object ref = languageOption_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
languageOption_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return The bytes for languageOption.
*/
public com.google.protobuf.ByteString
getLanguageOptionBytes() {
java.lang.Object ref = languageOption_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
languageOption_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The languageOption to set.
* @return This builder for chaining.
*/
public Builder setLanguageOption(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
languageOption_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @return This builder for chaining.
*/
public Builder clearLanguageOption() {
languageOption_ = getDefaultInstance().getLanguageOption();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
* <pre>
* Required. The language specifications in BCP 47 format (for example, en-US,
* zh-CN, etc.) for the asset suggestions. Text will be in this language.
* Usually matches one of the campaign target languages.
* </pre>
*
* <code>string language_option = 2 [(.google.api.field_behavior) = REQUIRED];</code>
* @param value The bytes for languageOption to set.
* @return This builder for chaining.
*/
public Builder setLanguageOptionBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
languageOption_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private com.google.protobuf.LazyStringArrayList placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
private void ensurePlaceIdsIsMutable() {
if (!placeIds_.isModifiable()) {
placeIds_ = new com.google.protobuf.LazyStringArrayList(placeIds_);
}
bitField0_ |= 0x00000004;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return A list containing the placeIds.
*/
public com.google.protobuf.ProtocolStringList
getPlaceIdsList() {
placeIds_.makeImmutable();
return placeIds_;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return The count of placeIds.
*/
public int getPlaceIdsCount() {
return placeIds_.size();
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the element to return.
* @return The placeIds at the given index.
*/
public java.lang.String getPlaceIds(int index) {
return placeIds_.get(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index of the value to return.
* @return The bytes of the placeIds at the given index.
*/
public com.google.protobuf.ByteString
getPlaceIdsBytes(int index) {
return placeIds_.getByteString(index);
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param index The index to set the value at.
* @param value The placeIds to set.
* @return This builder for chaining.
*/
public Builder setPlaceIds(
int index, java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
ensurePlaceIdsIsMutable();
placeIds_.set(index, value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param value The placeIds to add.
* @return This builder for chaining.
*/
public Builder addPlaceIds(
java.lang.String value) {
if (value == null) { throw new NullPointerException(); }
ensurePlaceIdsIsMutable();
placeIds_.add(value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param values The placeIds to add.
* @return This builder for chaining.
*/
public Builder addAllPlaceIds(
java.lang.Iterable<java.lang.String> values) {
ensurePlaceIdsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
values, placeIds_);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @return This builder for chaining.
*/
public Builder clearPlaceIds() {
placeIds_ =
com.google.protobuf.LazyStringArrayList.emptyList();
bitField0_ = (bitField0_ & ~0x00000004);;
onChanged();
return this;
}
/**
* <pre>
* The Google Maps Place IDs of hotels for which assets are requested. See
* https://developers.google.com/places/web-service/place-id for more
* information.
* </pre>
*
* <code>repeated string place_ids = 4;</code>
* @param value The bytes of the placeIds to add.
* @return This builder for chaining.
*/
public Builder addPlaceIdsBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
ensurePlaceIdsIsMutable();
placeIds_.add(value);
bitField0_ |= 0x00000004;
onChanged();
return this;
}
@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.ads.googleads.v21.services.SuggestTravelAssetsRequest)
}
// @@protoc_insertion_point(class_scope:google.ads.googleads.v21.services.SuggestTravelAssetsRequest)
private static final com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest();
}
public static com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<SuggestTravelAssetsRequest>
PARSER = new com.google.protobuf.AbstractParser<SuggestTravelAssetsRequest>() {
@java.lang.Override
public SuggestTravelAssetsRequest 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<SuggestTravelAssetsRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SuggestTravelAssetsRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.ads.googleads.v21.services.SuggestTravelAssetsRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,274 | java-gkehub/proto-google-cloud-gkehub-v1alpha/src/main/java/com/google/cloud/gkehub/v1alpha/CommonFeatureState.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/gkehub/v1alpha/feature.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.gkehub.v1alpha;
/**
*
*
* <pre>
* CommonFeatureState contains Hub-wide Feature status information.
* </pre>
*
* Protobuf type {@code google.cloud.gkehub.v1alpha.CommonFeatureState}
*/
public final class CommonFeatureState extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.gkehub.v1alpha.CommonFeatureState)
CommonFeatureStateOrBuilder {
private static final long serialVersionUID = 0L;
// Use CommonFeatureState.newBuilder() to construct.
private CommonFeatureState(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private CommonFeatureState() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new CommonFeatureState();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.gkehub.v1alpha.FeatureProto
.internal_static_google_cloud_gkehub_v1alpha_CommonFeatureState_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.gkehub.v1alpha.FeatureProto
.internal_static_google_cloud_gkehub_v1alpha_CommonFeatureState_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.gkehub.v1alpha.CommonFeatureState.class,
com.google.cloud.gkehub.v1alpha.CommonFeatureState.Builder.class);
}
private int bitField0_;
private int featureStateCase_ = 0;
@SuppressWarnings("serial")
private java.lang.Object featureState_;
public enum FeatureStateCase
implements
com.google.protobuf.Internal.EnumLite,
com.google.protobuf.AbstractMessage.InternalOneOfEnum {
SERVICEMESH(100),
FEATURESTATE_NOT_SET(0);
private final int value;
private FeatureStateCase(int value) {
this.value = value;
}
/**
* @param value The number of the enum to look for.
* @return The enum associated with the given number.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static FeatureStateCase valueOf(int value) {
return forNumber(value);
}
public static FeatureStateCase forNumber(int value) {
switch (value) {
case 100:
return SERVICEMESH;
case 0:
return FEATURESTATE_NOT_SET;
default:
return null;
}
}
public int getNumber() {
return this.value;
}
};
public FeatureStateCase getFeatureStateCase() {
return FeatureStateCase.forNumber(featureStateCase_);
}
public static final int SERVICEMESH_FIELD_NUMBER = 100;
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*
* @return Whether the servicemesh field is set.
*/
@java.lang.Override
public boolean hasServicemesh() {
return featureStateCase_ == 100;
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*
* @return The servicemesh.
*/
@java.lang.Override
public com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState getServicemesh() {
if (featureStateCase_ == 100) {
return (com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_;
}
return com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.getDefaultInstance();
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
@java.lang.Override
public com.google.cloud.gkehub.servicemesh.v1alpha.FeatureStateOrBuilder
getServicemeshOrBuilder() {
if (featureStateCase_ == 100) {
return (com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_;
}
return com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.getDefaultInstance();
}
public static final int STATE_FIELD_NUMBER = 1;
private com.google.cloud.gkehub.v1alpha.FeatureState state_;
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*
* @return Whether the state field is set.
*/
@java.lang.Override
public boolean hasState() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*
* @return The state.
*/
@java.lang.Override
public com.google.cloud.gkehub.v1alpha.FeatureState getState() {
return state_ == null
? com.google.cloud.gkehub.v1alpha.FeatureState.getDefaultInstance()
: state_;
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public com.google.cloud.gkehub.v1alpha.FeatureStateOrBuilder getStateOrBuilder() {
return state_ == null
? com.google.cloud.gkehub.v1alpha.FeatureState.getDefaultInstance()
: state_;
}
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)) {
output.writeMessage(1, getState());
}
if (featureStateCase_ == 100) {
output.writeMessage(
100, (com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_);
}
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.CodedOutputStream.computeMessageSize(1, getState());
}
if (featureStateCase_ == 100) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
100, (com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_);
}
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.gkehub.v1alpha.CommonFeatureState)) {
return super.equals(obj);
}
com.google.cloud.gkehub.v1alpha.CommonFeatureState other =
(com.google.cloud.gkehub.v1alpha.CommonFeatureState) obj;
if (hasState() != other.hasState()) return false;
if (hasState()) {
if (!getState().equals(other.getState())) return false;
}
if (!getFeatureStateCase().equals(other.getFeatureStateCase())) return false;
switch (featureStateCase_) {
case 100:
if (!getServicemesh().equals(other.getServicemesh())) return false;
break;
case 0:
default:
}
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 (hasState()) {
hash = (37 * hash) + STATE_FIELD_NUMBER;
hash = (53 * hash) + getState().hashCode();
}
switch (featureStateCase_) {
case 100:
hash = (37 * hash) + SERVICEMESH_FIELD_NUMBER;
hash = (53 * hash) + getServicemesh().hashCode();
break;
case 0:
default:
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState 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.gkehub.v1alpha.CommonFeatureState parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState 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.gkehub.v1alpha.CommonFeatureState parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState 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.gkehub.v1alpha.CommonFeatureState parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState 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.gkehub.v1alpha.CommonFeatureState parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState 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.gkehub.v1alpha.CommonFeatureState 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;
}
/**
*
*
* <pre>
* CommonFeatureState contains Hub-wide Feature status information.
* </pre>
*
* Protobuf type {@code google.cloud.gkehub.v1alpha.CommonFeatureState}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.gkehub.v1alpha.CommonFeatureState)
com.google.cloud.gkehub.v1alpha.CommonFeatureStateOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.gkehub.v1alpha.FeatureProto
.internal_static_google_cloud_gkehub_v1alpha_CommonFeatureState_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.gkehub.v1alpha.FeatureProto
.internal_static_google_cloud_gkehub_v1alpha_CommonFeatureState_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.gkehub.v1alpha.CommonFeatureState.class,
com.google.cloud.gkehub.v1alpha.CommonFeatureState.Builder.class);
}
// Construct using com.google.cloud.gkehub.v1alpha.CommonFeatureState.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getStateFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (servicemeshBuilder_ != null) {
servicemeshBuilder_.clear();
}
state_ = null;
if (stateBuilder_ != null) {
stateBuilder_.dispose();
stateBuilder_ = null;
}
featureStateCase_ = 0;
featureState_ = null;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.gkehub.v1alpha.FeatureProto
.internal_static_google_cloud_gkehub_v1alpha_CommonFeatureState_descriptor;
}
@java.lang.Override
public com.google.cloud.gkehub.v1alpha.CommonFeatureState getDefaultInstanceForType() {
return com.google.cloud.gkehub.v1alpha.CommonFeatureState.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.gkehub.v1alpha.CommonFeatureState build() {
com.google.cloud.gkehub.v1alpha.CommonFeatureState result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.gkehub.v1alpha.CommonFeatureState buildPartial() {
com.google.cloud.gkehub.v1alpha.CommonFeatureState result =
new com.google.cloud.gkehub.v1alpha.CommonFeatureState(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
buildPartialOneofs(result);
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.gkehub.v1alpha.CommonFeatureState result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.state_ = stateBuilder_ == null ? state_ : stateBuilder_.build();
to_bitField0_ |= 0x00000001;
}
result.bitField0_ |= to_bitField0_;
}
private void buildPartialOneofs(com.google.cloud.gkehub.v1alpha.CommonFeatureState result) {
result.featureStateCase_ = featureStateCase_;
result.featureState_ = this.featureState_;
if (featureStateCase_ == 100 && servicemeshBuilder_ != null) {
result.featureState_ = servicemeshBuilder_.build();
}
}
@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.gkehub.v1alpha.CommonFeatureState) {
return mergeFrom((com.google.cloud.gkehub.v1alpha.CommonFeatureState) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.gkehub.v1alpha.CommonFeatureState other) {
if (other == com.google.cloud.gkehub.v1alpha.CommonFeatureState.getDefaultInstance())
return this;
if (other.hasState()) {
mergeState(other.getState());
}
switch (other.getFeatureStateCase()) {
case SERVICEMESH:
{
mergeServicemesh(other.getServicemesh());
break;
}
case FEATURESTATE_NOT_SET:
{
break;
}
}
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 10:
{
input.readMessage(getStateFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 10
case 802:
{
input.readMessage(getServicemeshFieldBuilder().getBuilder(), extensionRegistry);
featureStateCase_ = 100;
break;
} // case 802
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 featureStateCase_ = 0;
private java.lang.Object featureState_;
public FeatureStateCase getFeatureStateCase() {
return FeatureStateCase.forNumber(featureStateCase_);
}
public Builder clearFeatureState() {
featureStateCase_ = 0;
featureState_ = null;
onChanged();
return this;
}
private int bitField0_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState,
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.Builder,
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureStateOrBuilder>
servicemeshBuilder_;
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*
* @return Whether the servicemesh field is set.
*/
@java.lang.Override
public boolean hasServicemesh() {
return featureStateCase_ == 100;
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*
* @return The servicemesh.
*/
@java.lang.Override
public com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState getServicemesh() {
if (servicemeshBuilder_ == null) {
if (featureStateCase_ == 100) {
return (com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_;
}
return com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.getDefaultInstance();
} else {
if (featureStateCase_ == 100) {
return servicemeshBuilder_.getMessage();
}
return com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.getDefaultInstance();
}
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
public Builder setServicemesh(com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState value) {
if (servicemeshBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
featureState_ = value;
onChanged();
} else {
servicemeshBuilder_.setMessage(value);
}
featureStateCase_ = 100;
return this;
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
public Builder setServicemesh(
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.Builder builderForValue) {
if (servicemeshBuilder_ == null) {
featureState_ = builderForValue.build();
onChanged();
} else {
servicemeshBuilder_.setMessage(builderForValue.build());
}
featureStateCase_ = 100;
return this;
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
public Builder mergeServicemesh(
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState value) {
if (servicemeshBuilder_ == null) {
if (featureStateCase_ == 100
&& featureState_
!= com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.getDefaultInstance()) {
featureState_ =
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.newBuilder(
(com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_)
.mergeFrom(value)
.buildPartial();
} else {
featureState_ = value;
}
onChanged();
} else {
if (featureStateCase_ == 100) {
servicemeshBuilder_.mergeFrom(value);
} else {
servicemeshBuilder_.setMessage(value);
}
}
featureStateCase_ = 100;
return this;
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
public Builder clearServicemesh() {
if (servicemeshBuilder_ == null) {
if (featureStateCase_ == 100) {
featureStateCase_ = 0;
featureState_ = null;
onChanged();
}
} else {
if (featureStateCase_ == 100) {
featureStateCase_ = 0;
featureState_ = null;
}
servicemeshBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
public com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.Builder
getServicemeshBuilder() {
return getServicemeshFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
@java.lang.Override
public com.google.cloud.gkehub.servicemesh.v1alpha.FeatureStateOrBuilder
getServicemeshOrBuilder() {
if ((featureStateCase_ == 100) && (servicemeshBuilder_ != null)) {
return servicemeshBuilder_.getMessageOrBuilder();
} else {
if (featureStateCase_ == 100) {
return (com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_;
}
return com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.getDefaultInstance();
}
}
/**
*
*
* <pre>
* Service Mesh-specific state.
* </pre>
*
* <code>.google.cloud.gkehub.servicemesh.v1alpha.FeatureState servicemesh = 100;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState,
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.Builder,
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureStateOrBuilder>
getServicemeshFieldBuilder() {
if (servicemeshBuilder_ == null) {
if (!(featureStateCase_ == 100)) {
featureState_ =
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.getDefaultInstance();
}
servicemeshBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState,
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState.Builder,
com.google.cloud.gkehub.servicemesh.v1alpha.FeatureStateOrBuilder>(
(com.google.cloud.gkehub.servicemesh.v1alpha.FeatureState) featureState_,
getParentForChildren(),
isClean());
featureState_ = null;
}
featureStateCase_ = 100;
onChanged();
return servicemeshBuilder_;
}
private com.google.cloud.gkehub.v1alpha.FeatureState state_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkehub.v1alpha.FeatureState,
com.google.cloud.gkehub.v1alpha.FeatureState.Builder,
com.google.cloud.gkehub.v1alpha.FeatureStateOrBuilder>
stateBuilder_;
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*
* @return Whether the state field is set.
*/
public boolean hasState() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*
* @return The state.
*/
public com.google.cloud.gkehub.v1alpha.FeatureState getState() {
if (stateBuilder_ == null) {
return state_ == null
? com.google.cloud.gkehub.v1alpha.FeatureState.getDefaultInstance()
: state_;
} else {
return stateBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder setState(com.google.cloud.gkehub.v1alpha.FeatureState value) {
if (stateBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
state_ = value;
} else {
stateBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder setState(com.google.cloud.gkehub.v1alpha.FeatureState.Builder builderForValue) {
if (stateBuilder_ == null) {
state_ = builderForValue.build();
} else {
stateBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder mergeState(com.google.cloud.gkehub.v1alpha.FeatureState value) {
if (stateBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& state_ != null
&& state_ != com.google.cloud.gkehub.v1alpha.FeatureState.getDefaultInstance()) {
getStateBuilder().mergeFrom(value);
} else {
state_ = value;
}
} else {
stateBuilder_.mergeFrom(value);
}
if (state_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder clearState() {
bitField0_ = (bitField0_ & ~0x00000002);
state_ = null;
if (stateBuilder_ != null) {
stateBuilder_.dispose();
stateBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.gkehub.v1alpha.FeatureState.Builder getStateBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getStateFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.gkehub.v1alpha.FeatureStateOrBuilder getStateOrBuilder() {
if (stateBuilder_ != null) {
return stateBuilder_.getMessageOrBuilder();
} else {
return state_ == null
? com.google.cloud.gkehub.v1alpha.FeatureState.getDefaultInstance()
: state_;
}
}
/**
*
*
* <pre>
* Output only. The "running state" of the Feature in this Hub.
* </pre>
*
* <code>
* .google.cloud.gkehub.v1alpha.FeatureState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkehub.v1alpha.FeatureState,
com.google.cloud.gkehub.v1alpha.FeatureState.Builder,
com.google.cloud.gkehub.v1alpha.FeatureStateOrBuilder>
getStateFieldBuilder() {
if (stateBuilder_ == null) {
stateBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.gkehub.v1alpha.FeatureState,
com.google.cloud.gkehub.v1alpha.FeatureState.Builder,
com.google.cloud.gkehub.v1alpha.FeatureStateOrBuilder>(
getState(), getParentForChildren(), isClean());
state_ = null;
}
return stateBuilder_;
}
@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.gkehub.v1alpha.CommonFeatureState)
}
// @@protoc_insertion_point(class_scope:google.cloud.gkehub.v1alpha.CommonFeatureState)
private static final com.google.cloud.gkehub.v1alpha.CommonFeatureState DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.gkehub.v1alpha.CommonFeatureState();
}
public static com.google.cloud.gkehub.v1alpha.CommonFeatureState getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<CommonFeatureState> PARSER =
new com.google.protobuf.AbstractParser<CommonFeatureState>() {
@java.lang.Override
public CommonFeatureState 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<CommonFeatureState> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<CommonFeatureState> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.gkehub.v1alpha.CommonFeatureState getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,289 | java-texttospeech/proto-google-cloud-texttospeech-v1beta1/src/main/java/com/google/cloud/texttospeech/v1beta1/SynthesizeLongAudioMetadata.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/texttospeech/v1beta1/cloud_tts_lrs.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.texttospeech.v1beta1;
/**
*
*
* <pre>
* Metadata for response returned by the `SynthesizeLongAudio` method.
* </pre>
*
* Protobuf type {@code google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata}
*/
public final class SynthesizeLongAudioMetadata extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata)
SynthesizeLongAudioMetadataOrBuilder {
private static final long serialVersionUID = 0L;
// Use SynthesizeLongAudioMetadata.newBuilder() to construct.
private SynthesizeLongAudioMetadata(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SynthesizeLongAudioMetadata() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new SynthesizeLongAudioMetadata();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesisProto
.internal_static_google_cloud_texttospeech_v1beta1_SynthesizeLongAudioMetadata_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesisProto
.internal_static_google_cloud_texttospeech_v1beta1_SynthesizeLongAudioMetadata_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.class,
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.Builder.class);
}
private int bitField0_;
public static final int START_TIME_FIELD_NUMBER = 1;
private com.google.protobuf.Timestamp startTime_;
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*
* @return Whether the startTime field is set.
*/
@java.lang.Override
public boolean hasStartTime() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*
* @return The startTime.
*/
@java.lang.Override
public com.google.protobuf.Timestamp getStartTime() {
return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_;
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
@java.lang.Override
public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() {
return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_;
}
public static final int LAST_UPDATE_TIME_FIELD_NUMBER = 2;
private com.google.protobuf.Timestamp lastUpdateTime_;
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*
* @deprecated google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.last_update_time is
* deprecated. See google/cloud/texttospeech/v1beta1/cloud_tts_lrs.proto;l=84
* @return Whether the lastUpdateTime field is set.
*/
@java.lang.Override
@java.lang.Deprecated
public boolean hasLastUpdateTime() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*
* @deprecated google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.last_update_time is
* deprecated. See google/cloud/texttospeech/v1beta1/cloud_tts_lrs.proto;l=84
* @return The lastUpdateTime.
*/
@java.lang.Override
@java.lang.Deprecated
public com.google.protobuf.Timestamp getLastUpdateTime() {
return lastUpdateTime_ == null
? com.google.protobuf.Timestamp.getDefaultInstance()
: lastUpdateTime_;
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
@java.lang.Override
@java.lang.Deprecated
public com.google.protobuf.TimestampOrBuilder getLastUpdateTimeOrBuilder() {
return lastUpdateTime_ == null
? com.google.protobuf.Timestamp.getDefaultInstance()
: lastUpdateTime_;
}
public static final int PROGRESS_PERCENTAGE_FIELD_NUMBER = 3;
private double progressPercentage_ = 0D;
/**
*
*
* <pre>
* The progress of the most recent processing update in percentage, ie. 70.0%.
* </pre>
*
* <code>double progress_percentage = 3;</code>
*
* @return The progressPercentage.
*/
@java.lang.Override
public double getProgressPercentage() {
return progressPercentage_;
}
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)) {
output.writeMessage(1, getStartTime());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getLastUpdateTime());
}
if (java.lang.Double.doubleToRawLongBits(progressPercentage_) != 0) {
output.writeDouble(3, progressPercentage_);
}
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.CodedOutputStream.computeMessageSize(1, getStartTime());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getLastUpdateTime());
}
if (java.lang.Double.doubleToRawLongBits(progressPercentage_) != 0) {
size += com.google.protobuf.CodedOutputStream.computeDoubleSize(3, progressPercentage_);
}
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.texttospeech.v1beta1.SynthesizeLongAudioMetadata)) {
return super.equals(obj);
}
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata other =
(com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata) obj;
if (hasStartTime() != other.hasStartTime()) return false;
if (hasStartTime()) {
if (!getStartTime().equals(other.getStartTime())) return false;
}
if (hasLastUpdateTime() != other.hasLastUpdateTime()) return false;
if (hasLastUpdateTime()) {
if (!getLastUpdateTime().equals(other.getLastUpdateTime())) return false;
}
if (java.lang.Double.doubleToLongBits(getProgressPercentage())
!= java.lang.Double.doubleToLongBits(other.getProgressPercentage())) 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 (hasStartTime()) {
hash = (37 * hash) + START_TIME_FIELD_NUMBER;
hash = (53 * hash) + getStartTime().hashCode();
}
if (hasLastUpdateTime()) {
hash = (37 * hash) + LAST_UPDATE_TIME_FIELD_NUMBER;
hash = (53 * hash) + getLastUpdateTime().hashCode();
}
hash = (37 * hash) + PROGRESS_PERCENTAGE_FIELD_NUMBER;
hash =
(53 * hash)
+ com.google.protobuf.Internal.hashLong(
java.lang.Double.doubleToLongBits(getProgressPercentage()));
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata 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.texttospeech.v1beta1.SynthesizeLongAudioMetadata parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata 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.texttospeech.v1beta1.SynthesizeLongAudioMetadata parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata 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.texttospeech.v1beta1.SynthesizeLongAudioMetadata
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata
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.texttospeech.v1beta1.SynthesizeLongAudioMetadata parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata 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.texttospeech.v1beta1.SynthesizeLongAudioMetadata 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;
}
/**
*
*
* <pre>
* Metadata for response returned by the `SynthesizeLongAudio` method.
* </pre>
*
* Protobuf type {@code google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata)
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadataOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesisProto
.internal_static_google_cloud_texttospeech_v1beta1_SynthesizeLongAudioMetadata_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesisProto
.internal_static_google_cloud_texttospeech_v1beta1_SynthesizeLongAudioMetadata_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.class,
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.Builder.class);
}
// Construct using
// com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getStartTimeFieldBuilder();
getLastUpdateTimeFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
startTime_ = null;
if (startTimeBuilder_ != null) {
startTimeBuilder_.dispose();
startTimeBuilder_ = null;
}
lastUpdateTime_ = null;
if (lastUpdateTimeBuilder_ != null) {
lastUpdateTimeBuilder_.dispose();
lastUpdateTimeBuilder_ = null;
}
progressPercentage_ = 0D;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesisProto
.internal_static_google_cloud_texttospeech_v1beta1_SynthesizeLongAudioMetadata_descriptor;
}
@java.lang.Override
public com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata
getDefaultInstanceForType() {
return com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata build() {
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata buildPartial() {
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata result =
new com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.lastUpdateTime_ =
lastUpdateTimeBuilder_ == null ? lastUpdateTime_ : lastUpdateTimeBuilder_.build();
to_bitField0_ |= 0x00000002;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.progressPercentage_ = progressPercentage_;
}
result.bitField0_ |= to_bitField0_;
}
@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.texttospeech.v1beta1.SynthesizeLongAudioMetadata) {
return mergeFrom((com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata other) {
if (other
== com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.getDefaultInstance())
return this;
if (other.hasStartTime()) {
mergeStartTime(other.getStartTime());
}
if (other.hasLastUpdateTime()) {
mergeLastUpdateTime(other.getLastUpdateTime());
}
if (other.getProgressPercentage() != 0D) {
setProgressPercentage(other.getProgressPercentage());
}
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 10:
{
input.readMessage(getStartTimeFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getLastUpdateTimeFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
case 25:
{
progressPercentage_ = input.readDouble();
bitField0_ |= 0x00000004;
break;
} // case 25
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 com.google.protobuf.Timestamp startTime_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Timestamp,
com.google.protobuf.Timestamp.Builder,
com.google.protobuf.TimestampOrBuilder>
startTimeBuilder_;
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*
* @return Whether the startTime field is set.
*/
public boolean hasStartTime() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*
* @return The startTime.
*/
public com.google.protobuf.Timestamp getStartTime() {
if (startTimeBuilder_ == null) {
return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_;
} else {
return startTimeBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
public Builder setStartTime(com.google.protobuf.Timestamp value) {
if (startTimeBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
startTime_ = value;
} else {
startTimeBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) {
if (startTimeBuilder_ == null) {
startTime_ = builderForValue.build();
} else {
startTimeBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
public Builder mergeStartTime(com.google.protobuf.Timestamp value) {
if (startTimeBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& startTime_ != null
&& startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
getStartTimeBuilder().mergeFrom(value);
} else {
startTime_ = value;
}
} else {
startTimeBuilder_.mergeFrom(value);
}
if (startTime_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
public Builder clearStartTime() {
bitField0_ = (bitField0_ & ~0x00000001);
startTime_ = null;
if (startTimeBuilder_ != null) {
startTimeBuilder_.dispose();
startTimeBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getStartTimeFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() {
if (startTimeBuilder_ != null) {
return startTimeBuilder_.getMessageOrBuilder();
} else {
return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_;
}
}
/**
*
*
* <pre>
* Time when the request was received.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Timestamp,
com.google.protobuf.Timestamp.Builder,
com.google.protobuf.TimestampOrBuilder>
getStartTimeFieldBuilder() {
if (startTimeBuilder_ == null) {
startTimeBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Timestamp,
com.google.protobuf.Timestamp.Builder,
com.google.protobuf.TimestampOrBuilder>(
getStartTime(), getParentForChildren(), isClean());
startTime_ = null;
}
return startTimeBuilder_;
}
private com.google.protobuf.Timestamp lastUpdateTime_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Timestamp,
com.google.protobuf.Timestamp.Builder,
com.google.protobuf.TimestampOrBuilder>
lastUpdateTimeBuilder_;
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*
* @deprecated google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.last_update_time is
* deprecated. See google/cloud/texttospeech/v1beta1/cloud_tts_lrs.proto;l=84
* @return Whether the lastUpdateTime field is set.
*/
@java.lang.Deprecated
public boolean hasLastUpdateTime() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*
* @deprecated google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata.last_update_time is
* deprecated. See google/cloud/texttospeech/v1beta1/cloud_tts_lrs.proto;l=84
* @return The lastUpdateTime.
*/
@java.lang.Deprecated
public com.google.protobuf.Timestamp getLastUpdateTime() {
if (lastUpdateTimeBuilder_ == null) {
return lastUpdateTime_ == null
? com.google.protobuf.Timestamp.getDefaultInstance()
: lastUpdateTime_;
} else {
return lastUpdateTimeBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
@java.lang.Deprecated
public Builder setLastUpdateTime(com.google.protobuf.Timestamp value) {
if (lastUpdateTimeBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
lastUpdateTime_ = value;
} else {
lastUpdateTimeBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
@java.lang.Deprecated
public Builder setLastUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) {
if (lastUpdateTimeBuilder_ == null) {
lastUpdateTime_ = builderForValue.build();
} else {
lastUpdateTimeBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
@java.lang.Deprecated
public Builder mergeLastUpdateTime(com.google.protobuf.Timestamp value) {
if (lastUpdateTimeBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& lastUpdateTime_ != null
&& lastUpdateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
getLastUpdateTimeBuilder().mergeFrom(value);
} else {
lastUpdateTime_ = value;
}
} else {
lastUpdateTimeBuilder_.mergeFrom(value);
}
if (lastUpdateTime_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
@java.lang.Deprecated
public Builder clearLastUpdateTime() {
bitField0_ = (bitField0_ & ~0x00000002);
lastUpdateTime_ = null;
if (lastUpdateTimeBuilder_ != null) {
lastUpdateTimeBuilder_.dispose();
lastUpdateTimeBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
@java.lang.Deprecated
public com.google.protobuf.Timestamp.Builder getLastUpdateTimeBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getLastUpdateTimeFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
@java.lang.Deprecated
public com.google.protobuf.TimestampOrBuilder getLastUpdateTimeOrBuilder() {
if (lastUpdateTimeBuilder_ != null) {
return lastUpdateTimeBuilder_.getMessageOrBuilder();
} else {
return lastUpdateTime_ == null
? com.google.protobuf.Timestamp.getDefaultInstance()
: lastUpdateTime_;
}
}
/**
*
*
* <pre>
* Deprecated. Do not use.
* </pre>
*
* <code>.google.protobuf.Timestamp last_update_time = 2 [deprecated = true];</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Timestamp,
com.google.protobuf.Timestamp.Builder,
com.google.protobuf.TimestampOrBuilder>
getLastUpdateTimeFieldBuilder() {
if (lastUpdateTimeBuilder_ == null) {
lastUpdateTimeBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.Timestamp,
com.google.protobuf.Timestamp.Builder,
com.google.protobuf.TimestampOrBuilder>(
getLastUpdateTime(), getParentForChildren(), isClean());
lastUpdateTime_ = null;
}
return lastUpdateTimeBuilder_;
}
private double progressPercentage_;
/**
*
*
* <pre>
* The progress of the most recent processing update in percentage, ie. 70.0%.
* </pre>
*
* <code>double progress_percentage = 3;</code>
*
* @return The progressPercentage.
*/
@java.lang.Override
public double getProgressPercentage() {
return progressPercentage_;
}
/**
*
*
* <pre>
* The progress of the most recent processing update in percentage, ie. 70.0%.
* </pre>
*
* <code>double progress_percentage = 3;</code>
*
* @param value The progressPercentage to set.
* @return This builder for chaining.
*/
public Builder setProgressPercentage(double value) {
progressPercentage_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* The progress of the most recent processing update in percentage, ie. 70.0%.
* </pre>
*
* <code>double progress_percentage = 3;</code>
*
* @return This builder for chaining.
*/
public Builder clearProgressPercentage() {
bitField0_ = (bitField0_ & ~0x00000004);
progressPercentage_ = 0D;
onChanged();
return this;
}
@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.texttospeech.v1beta1.SynthesizeLongAudioMetadata)
}
// @@protoc_insertion_point(class_scope:google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata)
private static final com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata();
}
public static com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<SynthesizeLongAudioMetadata> PARSER =
new com.google.protobuf.AbstractParser<SynthesizeLongAudioMetadata>() {
@java.lang.Override
public SynthesizeLongAudioMetadata 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<SynthesizeLongAudioMetadata> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SynthesizeLongAudioMetadata> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.texttospeech.v1beta1.SynthesizeLongAudioMetadata
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,292 | java-analytics-admin/proto-google-analytics-admin-v1alpha/src/main/java/com/google/analytics/admin/v1alpha/UpdateKeyEventRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/analytics/admin/v1alpha/analytics_admin.proto
// Protobuf Java Version: 3.25.8
package com.google.analytics.admin.v1alpha;
/**
*
*
* <pre>
* Request message for UpdateKeyEvent RPC
* </pre>
*
* Protobuf type {@code google.analytics.admin.v1alpha.UpdateKeyEventRequest}
*/
public final class UpdateKeyEventRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.analytics.admin.v1alpha.UpdateKeyEventRequest)
UpdateKeyEventRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateKeyEventRequest.newBuilder() to construct.
private UpdateKeyEventRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateKeyEventRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateKeyEventRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateKeyEventRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateKeyEventRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.analytics.admin.v1alpha.UpdateKeyEventRequest.class,
com.google.analytics.admin.v1alpha.UpdateKeyEventRequest.Builder.class);
}
private int bitField0_;
public static final int KEY_EVENT_FIELD_NUMBER = 1;
private com.google.analytics.admin.v1alpha.KeyEvent keyEvent_;
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the keyEvent field is set.
*/
@java.lang.Override
public boolean hasKeyEvent() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The keyEvent.
*/
@java.lang.Override
public com.google.analytics.admin.v1alpha.KeyEvent getKeyEvent() {
return keyEvent_ == null
? com.google.analytics.admin.v1alpha.KeyEvent.getDefaultInstance()
: keyEvent_;
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.analytics.admin.v1alpha.KeyEventOrBuilder getKeyEventOrBuilder() {
return keyEvent_ == null
? com.google.analytics.admin.v1alpha.KeyEvent.getDefaultInstance()
: keyEvent_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getKeyEvent());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getKeyEvent());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.analytics.admin.v1alpha.UpdateKeyEventRequest)) {
return super.equals(obj);
}
com.google.analytics.admin.v1alpha.UpdateKeyEventRequest other =
(com.google.analytics.admin.v1alpha.UpdateKeyEventRequest) obj;
if (hasKeyEvent() != other.hasKeyEvent()) return false;
if (hasKeyEvent()) {
if (!getKeyEvent().equals(other.getKeyEvent())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasKeyEvent()) {
hash = (37 * hash) + KEY_EVENT_FIELD_NUMBER;
hash = (53 * hash) + getKeyEvent().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest parseFrom(
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest 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.analytics.admin.v1alpha.UpdateKeyEventRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest 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.analytics.admin.v1alpha.UpdateKeyEventRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest 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.analytics.admin.v1alpha.UpdateKeyEventRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest 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.analytics.admin.v1alpha.UpdateKeyEventRequest 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;
}
/**
*
*
* <pre>
* Request message for UpdateKeyEvent RPC
* </pre>
*
* Protobuf type {@code google.analytics.admin.v1alpha.UpdateKeyEventRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.analytics.admin.v1alpha.UpdateKeyEventRequest)
com.google.analytics.admin.v1alpha.UpdateKeyEventRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateKeyEventRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateKeyEventRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.analytics.admin.v1alpha.UpdateKeyEventRequest.class,
com.google.analytics.admin.v1alpha.UpdateKeyEventRequest.Builder.class);
}
// Construct using com.google.analytics.admin.v1alpha.UpdateKeyEventRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getKeyEventFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
keyEvent_ = null;
if (keyEventBuilder_ != null) {
keyEventBuilder_.dispose();
keyEventBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateKeyEventRequest_descriptor;
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateKeyEventRequest getDefaultInstanceForType() {
return com.google.analytics.admin.v1alpha.UpdateKeyEventRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateKeyEventRequest build() {
com.google.analytics.admin.v1alpha.UpdateKeyEventRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateKeyEventRequest buildPartial() {
com.google.analytics.admin.v1alpha.UpdateKeyEventRequest result =
new com.google.analytics.admin.v1alpha.UpdateKeyEventRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.analytics.admin.v1alpha.UpdateKeyEventRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.keyEvent_ = keyEventBuilder_ == null ? keyEvent_ : keyEventBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.analytics.admin.v1alpha.UpdateKeyEventRequest) {
return mergeFrom((com.google.analytics.admin.v1alpha.UpdateKeyEventRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.analytics.admin.v1alpha.UpdateKeyEventRequest other) {
if (other == com.google.analytics.admin.v1alpha.UpdateKeyEventRequest.getDefaultInstance())
return this;
if (other.hasKeyEvent()) {
mergeKeyEvent(other.getKeyEvent());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(getKeyEventFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.analytics.admin.v1alpha.KeyEvent keyEvent_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.analytics.admin.v1alpha.KeyEvent,
com.google.analytics.admin.v1alpha.KeyEvent.Builder,
com.google.analytics.admin.v1alpha.KeyEventOrBuilder>
keyEventBuilder_;
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the keyEvent field is set.
*/
public boolean hasKeyEvent() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The keyEvent.
*/
public com.google.analytics.admin.v1alpha.KeyEvent getKeyEvent() {
if (keyEventBuilder_ == null) {
return keyEvent_ == null
? com.google.analytics.admin.v1alpha.KeyEvent.getDefaultInstance()
: keyEvent_;
} else {
return keyEventBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setKeyEvent(com.google.analytics.admin.v1alpha.KeyEvent value) {
if (keyEventBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
keyEvent_ = value;
} else {
keyEventBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setKeyEvent(
com.google.analytics.admin.v1alpha.KeyEvent.Builder builderForValue) {
if (keyEventBuilder_ == null) {
keyEvent_ = builderForValue.build();
} else {
keyEventBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeKeyEvent(com.google.analytics.admin.v1alpha.KeyEvent value) {
if (keyEventBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& keyEvent_ != null
&& keyEvent_ != com.google.analytics.admin.v1alpha.KeyEvent.getDefaultInstance()) {
getKeyEventBuilder().mergeFrom(value);
} else {
keyEvent_ = value;
}
} else {
keyEventBuilder_.mergeFrom(value);
}
if (keyEvent_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearKeyEvent() {
bitField0_ = (bitField0_ & ~0x00000001);
keyEvent_ = null;
if (keyEventBuilder_ != null) {
keyEventBuilder_.dispose();
keyEventBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.analytics.admin.v1alpha.KeyEvent.Builder getKeyEventBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getKeyEventFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.analytics.admin.v1alpha.KeyEventOrBuilder getKeyEventOrBuilder() {
if (keyEventBuilder_ != null) {
return keyEventBuilder_.getMessageOrBuilder();
} else {
return keyEvent_ == null
? com.google.analytics.admin.v1alpha.KeyEvent.getDefaultInstance()
: keyEvent_;
}
}
/**
*
*
* <pre>
* Required. The Key Event to update.
* The `name` field is used to identify the settings to be updated.
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.KeyEvent key_event = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.analytics.admin.v1alpha.KeyEvent,
com.google.analytics.admin.v1alpha.KeyEvent.Builder,
com.google.analytics.admin.v1alpha.KeyEventOrBuilder>
getKeyEventFieldBuilder() {
if (keyEventBuilder_ == null) {
keyEventBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.analytics.admin.v1alpha.KeyEvent,
com.google.analytics.admin.v1alpha.KeyEvent.Builder,
com.google.analytics.admin.v1alpha.KeyEventOrBuilder>(
getKeyEvent(), getParentForChildren(), isClean());
keyEvent_ = null;
}
return keyEventBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Field names must be in snake
* case (e.g., "field_to_update"). Omitted fields will not be updated. To
* replace the entire entity, use one path with the string "*" to match all
* fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.analytics.admin.v1alpha.UpdateKeyEventRequest)
}
// @@protoc_insertion_point(class_scope:google.analytics.admin.v1alpha.UpdateKeyEventRequest)
private static final com.google.analytics.admin.v1alpha.UpdateKeyEventRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.analytics.admin.v1alpha.UpdateKeyEventRequest();
}
public static com.google.analytics.admin.v1alpha.UpdateKeyEventRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateKeyEventRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateKeyEventRequest>() {
@java.lang.Override
public UpdateKeyEventRequest 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<UpdateKeyEventRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateKeyEventRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateKeyEventRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,324 | java-securitycenter/proto-google-cloud-securitycenter-v1p1beta1/src/main/java/com/google/cloud/securitycenter/v1p1beta1/UpdateNotificationConfigRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/securitycenter/v1p1beta1/securitycenter_service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.securitycenter.v1p1beta1;
/**
*
*
* <pre>
* Request message for updating a notification config.
* </pre>
*
* Protobuf type {@code google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest}
*/
public final class UpdateNotificationConfigRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest)
UpdateNotificationConfigRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateNotificationConfigRequest.newBuilder() to construct.
private UpdateNotificationConfigRequest(
com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateNotificationConfigRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateNotificationConfigRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.securitycenter.v1p1beta1.SecuritycenterService
.internal_static_google_cloud_securitycenter_v1p1beta1_UpdateNotificationConfigRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.securitycenter.v1p1beta1.SecuritycenterService
.internal_static_google_cloud_securitycenter_v1p1beta1_UpdateNotificationConfigRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest.class,
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest.Builder
.class);
}
private int bitField0_;
public static final int NOTIFICATION_CONFIG_FIELD_NUMBER = 1;
private com.google.cloud.securitycenter.v1p1beta1.NotificationConfig notificationConfig_;
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the notificationConfig field is set.
*/
@java.lang.Override
public boolean hasNotificationConfig() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The notificationConfig.
*/
@java.lang.Override
public com.google.cloud.securitycenter.v1p1beta1.NotificationConfig getNotificationConfig() {
return notificationConfig_ == null
? com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.getDefaultInstance()
: notificationConfig_;
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.securitycenter.v1p1beta1.NotificationConfigOrBuilder
getNotificationConfigOrBuilder() {
return notificationConfig_ == null
? com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.getDefaultInstance()
: notificationConfig_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getNotificationConfig());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getNotificationConfig());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest)) {
return super.equals(obj);
}
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest other =
(com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest) obj;
if (hasNotificationConfig() != other.hasNotificationConfig()) return false;
if (hasNotificationConfig()) {
if (!getNotificationConfig().equals(other.getNotificationConfig())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasNotificationConfig()) {
hash = (37 * hash) + NOTIFICATION_CONFIG_FIELD_NUMBER;
hash = (53 * hash) + getNotificationConfig().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest 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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest 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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest 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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest 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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest 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;
}
/**
*
*
* <pre>
* Request message for updating a notification config.
* </pre>
*
* Protobuf type {@code google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest)
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.securitycenter.v1p1beta1.SecuritycenterService
.internal_static_google_cloud_securitycenter_v1p1beta1_UpdateNotificationConfigRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.securitycenter.v1p1beta1.SecuritycenterService
.internal_static_google_cloud_securitycenter_v1p1beta1_UpdateNotificationConfigRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest.class,
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest.Builder
.class);
}
// Construct using
// com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getNotificationConfigFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
notificationConfig_ = null;
if (notificationConfigBuilder_ != null) {
notificationConfigBuilder_.dispose();
notificationConfigBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.securitycenter.v1p1beta1.SecuritycenterService
.internal_static_google_cloud_securitycenter_v1p1beta1_UpdateNotificationConfigRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
getDefaultInstanceForType() {
return com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest build() {
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest result =
buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
buildPartial() {
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest result =
new com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.notificationConfig_ =
notificationConfigBuilder_ == null
? notificationConfig_
: notificationConfigBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest) {
return mergeFrom(
(com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest other) {
if (other
== com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
.getDefaultInstance()) return this;
if (other.hasNotificationConfig()) {
mergeNotificationConfig(other.getNotificationConfig());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(
getNotificationConfigFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.cloud.securitycenter.v1p1beta1.NotificationConfig notificationConfig_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig,
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.Builder,
com.google.cloud.securitycenter.v1p1beta1.NotificationConfigOrBuilder>
notificationConfigBuilder_;
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the notificationConfig field is set.
*/
public boolean hasNotificationConfig() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The notificationConfig.
*/
public com.google.cloud.securitycenter.v1p1beta1.NotificationConfig getNotificationConfig() {
if (notificationConfigBuilder_ == null) {
return notificationConfig_ == null
? com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.getDefaultInstance()
: notificationConfig_;
} else {
return notificationConfigBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setNotificationConfig(
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig value) {
if (notificationConfigBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
notificationConfig_ = value;
} else {
notificationConfigBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setNotificationConfig(
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.Builder builderForValue) {
if (notificationConfigBuilder_ == null) {
notificationConfig_ = builderForValue.build();
} else {
notificationConfigBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeNotificationConfig(
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig value) {
if (notificationConfigBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& notificationConfig_ != null
&& notificationConfig_
!= com.google.cloud.securitycenter.v1p1beta1.NotificationConfig
.getDefaultInstance()) {
getNotificationConfigBuilder().mergeFrom(value);
} else {
notificationConfig_ = value;
}
} else {
notificationConfigBuilder_.mergeFrom(value);
}
if (notificationConfig_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearNotificationConfig() {
bitField0_ = (bitField0_ & ~0x00000001);
notificationConfig_ = null;
if (notificationConfigBuilder_ != null) {
notificationConfigBuilder_.dispose();
notificationConfigBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.Builder
getNotificationConfigBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getNotificationConfigFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.securitycenter.v1p1beta1.NotificationConfigOrBuilder
getNotificationConfigOrBuilder() {
if (notificationConfigBuilder_ != null) {
return notificationConfigBuilder_.getMessageOrBuilder();
} else {
return notificationConfig_ == null
? com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.getDefaultInstance()
: notificationConfig_;
}
}
/**
*
*
* <pre>
* Required. The notification config to update.
* </pre>
*
* <code>
* .google.cloud.securitycenter.v1p1beta1.NotificationConfig notification_config = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig,
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.Builder,
com.google.cloud.securitycenter.v1p1beta1.NotificationConfigOrBuilder>
getNotificationConfigFieldBuilder() {
if (notificationConfigBuilder_ == null) {
notificationConfigBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig,
com.google.cloud.securitycenter.v1p1beta1.NotificationConfig.Builder,
com.google.cloud.securitycenter.v1p1beta1.NotificationConfigOrBuilder>(
getNotificationConfig(), getParentForChildren(), isClean());
notificationConfig_ = null;
}
return notificationConfigBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* The FieldMask to use when updating the notification config.
*
* If empty all mutable fields will be updated.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.securitycenter.v1p1beta1.UpdateNotificationConfigRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest)
private static final com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE =
new com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest();
}
public static com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateNotificationConfigRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateNotificationConfigRequest>() {
@java.lang.Override
public UpdateNotificationConfigRequest 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<UpdateNotificationConfigRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateNotificationConfigRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,352 | java-video-intelligence/proto-google-cloud-video-intelligence-v1p1beta1/src/main/java/com/google/cloud/videointelligence/v1p1beta1/AnnotateVideoProgress.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/videointelligence/v1p1beta1/video_intelligence.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.videointelligence.v1p1beta1;
/**
*
*
* <pre>
* Video annotation progress. Included in the `metadata`
* field of the `Operation` returned by the `GetOperation`
* call of the `google::longrunning::Operations` service.
* </pre>
*
* Protobuf type {@code google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress}
*/
public final class AnnotateVideoProgress extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress)
AnnotateVideoProgressOrBuilder {
private static final long serialVersionUID = 0L;
// Use AnnotateVideoProgress.newBuilder() to construct.
private AnnotateVideoProgress(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private AnnotateVideoProgress() {
annotationProgress_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new AnnotateVideoProgress();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p1beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p1beta1_AnnotateVideoProgress_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress.class,
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress.Builder.class);
}
public static final int ANNOTATION_PROGRESS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress>
annotationProgress_;
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress>
getAnnotationProgressList() {
return annotationProgress_;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public java.util.List<
? extends com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressOrBuilderList() {
return annotationProgress_;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public int getAnnotationProgressCount() {
return annotationProgress_.size();
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress getAnnotationProgress(
int index) {
return annotationProgress_.get(index);
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgressOrBuilder
getAnnotationProgressOrBuilder(int index) {
return annotationProgress_.get(index);
}
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 {
for (int i = 0; i < annotationProgress_.size(); i++) {
output.writeMessage(1, annotationProgress_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < annotationProgress_.size(); i++) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(1, annotationProgress_.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.videointelligence.v1p1beta1.AnnotateVideoProgress)) {
return super.equals(obj);
}
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress other =
(com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress) obj;
if (!getAnnotationProgressList().equals(other.getAnnotationProgressList())) 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 (getAnnotationProgressCount() > 0) {
hash = (37 * hash) + ANNOTATION_PROGRESS_FIELD_NUMBER;
hash = (53 * hash) + getAnnotationProgressList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress 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.videointelligence.v1p1beta1.AnnotateVideoProgress parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress 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.videointelligence.v1p1beta1.AnnotateVideoProgress parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress 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.videointelligence.v1p1beta1.AnnotateVideoProgress
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress
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.videointelligence.v1p1beta1.AnnotateVideoProgress parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress 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.videointelligence.v1p1beta1.AnnotateVideoProgress 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;
}
/**
*
*
* <pre>
* Video annotation progress. Included in the `metadata`
* field of the `Operation` returned by the `GetOperation`
* call of the `google::longrunning::Operations` service.
* </pre>
*
* Protobuf type {@code google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress)
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgressOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p1beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p1beta1_AnnotateVideoProgress_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress.class,
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress.Builder.class);
}
// Construct using
// com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (annotationProgressBuilder_ == null) {
annotationProgress_ = java.util.Collections.emptyList();
} else {
annotationProgress_ = null;
annotationProgressBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p1beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress
getDefaultInstanceForType() {
return com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress
.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress build() {
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress buildPartial() {
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress result =
new com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress result) {
if (annotationProgressBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
annotationProgress_ = java.util.Collections.unmodifiableList(annotationProgress_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.annotationProgress_ = annotationProgress_;
} else {
result.annotationProgress_ = annotationProgressBuilder_.build();
}
}
private void buildPartial0(
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress result) {
int from_bitField0_ = bitField0_;
}
@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.videointelligence.v1p1beta1.AnnotateVideoProgress) {
return mergeFrom(
(com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress other) {
if (other
== com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress
.getDefaultInstance()) return this;
if (annotationProgressBuilder_ == null) {
if (!other.annotationProgress_.isEmpty()) {
if (annotationProgress_.isEmpty()) {
annotationProgress_ = other.annotationProgress_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureAnnotationProgressIsMutable();
annotationProgress_.addAll(other.annotationProgress_);
}
onChanged();
}
} else {
if (!other.annotationProgress_.isEmpty()) {
if (annotationProgressBuilder_.isEmpty()) {
annotationProgressBuilder_.dispose();
annotationProgressBuilder_ = null;
annotationProgress_ = other.annotationProgress_;
bitField0_ = (bitField0_ & ~0x00000001);
annotationProgressBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getAnnotationProgressFieldBuilder()
: null;
} else {
annotationProgressBuilder_.addAllMessages(other.annotationProgress_);
}
}
}
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 10:
{
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress m =
input.readMessage(
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress
.parser(),
extensionRegistry);
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(m);
} else {
annotationProgressBuilder_.addMessage(m);
}
break;
} // case 10
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.videointelligence.v1p1beta1.VideoAnnotationProgress>
annotationProgress_ = java.util.Collections.emptyList();
private void ensureAnnotationProgressIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
annotationProgress_ =
new java.util.ArrayList<
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress>(
annotationProgress_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgressOrBuilder>
annotationProgressBuilder_;
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress>
getAnnotationProgressList() {
if (annotationProgressBuilder_ == null) {
return java.util.Collections.unmodifiableList(annotationProgress_);
} else {
return annotationProgressBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public int getAnnotationProgressCount() {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.size();
} else {
return annotationProgressBuilder_.getCount();
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress
getAnnotationProgress(int index) {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.get(index);
} else {
return annotationProgressBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder setAnnotationProgress(
int index, com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.set(index, value);
onChanged();
} else {
annotationProgressBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder setAnnotationProgress(
int index,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.set(index, builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.add(value);
onChanged();
} else {
annotationProgressBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
int index, com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.add(index, value);
onChanged();
} else {
annotationProgressBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
int index,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(index, builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAllAnnotationProgress(
java.lang.Iterable<
? extends com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress>
values) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, annotationProgress_);
onChanged();
} else {
annotationProgressBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder clearAnnotationProgress() {
if (annotationProgressBuilder_ == null) {
annotationProgress_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
annotationProgressBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder removeAnnotationProgress(int index) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.remove(index);
onChanged();
} else {
annotationProgressBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder
getAnnotationProgressBuilder(int index) {
return getAnnotationProgressFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgressOrBuilder
getAnnotationProgressOrBuilder(int index) {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.get(index);
} else {
return annotationProgressBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<
? extends com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressOrBuilderList() {
if (annotationProgressBuilder_ != null) {
return annotationProgressBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(annotationProgress_);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder
addAnnotationProgressBuilder() {
return getAnnotationProgressFieldBuilder()
.addBuilder(
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress
.getDefaultInstance());
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder
addAnnotationProgressBuilder(int index) {
return getAnnotationProgressFieldBuilder()
.addBuilder(
index,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress
.getDefaultInstance());
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder>
getAnnotationProgressBuilderList() {
return getAnnotationProgressFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressFieldBuilder() {
if (annotationProgressBuilder_ == null) {
annotationProgressBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p1beta1.VideoAnnotationProgressOrBuilder>(
annotationProgress_,
((bitField0_ & 0x00000001) != 0),
getParentForChildren(),
isClean());
annotationProgress_ = null;
}
return annotationProgressBuilder_;
}
@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.videointelligence.v1p1beta1.AnnotateVideoProgress)
}
// @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress)
private static final com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress();
}
public static com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<AnnotateVideoProgress> PARSER =
new com.google.protobuf.AbstractParser<AnnotateVideoProgress>() {
@java.lang.Override
public AnnotateVideoProgress 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<AnnotateVideoProgress> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<AnnotateVideoProgress> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,352 | java-video-intelligence/proto-google-cloud-video-intelligence-v1p2beta1/src/main/java/com/google/cloud/videointelligence/v1p2beta1/AnnotateVideoProgress.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/videointelligence/v1p2beta1/video_intelligence.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.videointelligence.v1p2beta1;
/**
*
*
* <pre>
* Video annotation progress. Included in the `metadata`
* field of the `Operation` returned by the `GetOperation`
* call of the `google::longrunning::Operations` service.
* </pre>
*
* Protobuf type {@code google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress}
*/
public final class AnnotateVideoProgress extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress)
AnnotateVideoProgressOrBuilder {
private static final long serialVersionUID = 0L;
// Use AnnotateVideoProgress.newBuilder() to construct.
private AnnotateVideoProgress(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private AnnotateVideoProgress() {
annotationProgress_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new AnnotateVideoProgress();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p2beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p2beta1_AnnotateVideoProgress_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress.class,
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress.Builder.class);
}
public static final int ANNOTATION_PROGRESS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress>
annotationProgress_;
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress>
getAnnotationProgressList() {
return annotationProgress_;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public java.util.List<
? extends com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressOrBuilderList() {
return annotationProgress_;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public int getAnnotationProgressCount() {
return annotationProgress_.size();
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress getAnnotationProgress(
int index) {
return annotationProgress_.get(index);
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgressOrBuilder
getAnnotationProgressOrBuilder(int index) {
return annotationProgress_.get(index);
}
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 {
for (int i = 0; i < annotationProgress_.size(); i++) {
output.writeMessage(1, annotationProgress_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < annotationProgress_.size(); i++) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(1, annotationProgress_.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.videointelligence.v1p2beta1.AnnotateVideoProgress)) {
return super.equals(obj);
}
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress other =
(com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress) obj;
if (!getAnnotationProgressList().equals(other.getAnnotationProgressList())) 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 (getAnnotationProgressCount() > 0) {
hash = (37 * hash) + ANNOTATION_PROGRESS_FIELD_NUMBER;
hash = (53 * hash) + getAnnotationProgressList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress 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.videointelligence.v1p2beta1.AnnotateVideoProgress parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress 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.videointelligence.v1p2beta1.AnnotateVideoProgress parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress 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.videointelligence.v1p2beta1.AnnotateVideoProgress
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress
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.videointelligence.v1p2beta1.AnnotateVideoProgress parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress 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.videointelligence.v1p2beta1.AnnotateVideoProgress 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;
}
/**
*
*
* <pre>
* Video annotation progress. Included in the `metadata`
* field of the `Operation` returned by the `GetOperation`
* call of the `google::longrunning::Operations` service.
* </pre>
*
* Protobuf type {@code google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress)
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgressOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p2beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p2beta1_AnnotateVideoProgress_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress.class,
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress.Builder.class);
}
// Construct using
// com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (annotationProgressBuilder_ == null) {
annotationProgress_ = java.util.Collections.emptyList();
} else {
annotationProgress_ = null;
annotationProgressBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p2beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress
getDefaultInstanceForType() {
return com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress
.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress build() {
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress buildPartial() {
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress result =
new com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress result) {
if (annotationProgressBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
annotationProgress_ = java.util.Collections.unmodifiableList(annotationProgress_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.annotationProgress_ = annotationProgress_;
} else {
result.annotationProgress_ = annotationProgressBuilder_.build();
}
}
private void buildPartial0(
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress result) {
int from_bitField0_ = bitField0_;
}
@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.videointelligence.v1p2beta1.AnnotateVideoProgress) {
return mergeFrom(
(com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress other) {
if (other
== com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress
.getDefaultInstance()) return this;
if (annotationProgressBuilder_ == null) {
if (!other.annotationProgress_.isEmpty()) {
if (annotationProgress_.isEmpty()) {
annotationProgress_ = other.annotationProgress_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureAnnotationProgressIsMutable();
annotationProgress_.addAll(other.annotationProgress_);
}
onChanged();
}
} else {
if (!other.annotationProgress_.isEmpty()) {
if (annotationProgressBuilder_.isEmpty()) {
annotationProgressBuilder_.dispose();
annotationProgressBuilder_ = null;
annotationProgress_ = other.annotationProgress_;
bitField0_ = (bitField0_ & ~0x00000001);
annotationProgressBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getAnnotationProgressFieldBuilder()
: null;
} else {
annotationProgressBuilder_.addAllMessages(other.annotationProgress_);
}
}
}
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 10:
{
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress m =
input.readMessage(
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress
.parser(),
extensionRegistry);
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(m);
} else {
annotationProgressBuilder_.addMessage(m);
}
break;
} // case 10
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.videointelligence.v1p2beta1.VideoAnnotationProgress>
annotationProgress_ = java.util.Collections.emptyList();
private void ensureAnnotationProgressIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
annotationProgress_ =
new java.util.ArrayList<
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress>(
annotationProgress_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgressOrBuilder>
annotationProgressBuilder_;
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress>
getAnnotationProgressList() {
if (annotationProgressBuilder_ == null) {
return java.util.Collections.unmodifiableList(annotationProgress_);
} else {
return annotationProgressBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public int getAnnotationProgressCount() {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.size();
} else {
return annotationProgressBuilder_.getCount();
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress
getAnnotationProgress(int index) {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.get(index);
} else {
return annotationProgressBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder setAnnotationProgress(
int index, com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.set(index, value);
onChanged();
} else {
annotationProgressBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder setAnnotationProgress(
int index,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.set(index, builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.add(value);
onChanged();
} else {
annotationProgressBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
int index, com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.add(index, value);
onChanged();
} else {
annotationProgressBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
int index,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(index, builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAllAnnotationProgress(
java.lang.Iterable<
? extends com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress>
values) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, annotationProgress_);
onChanged();
} else {
annotationProgressBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder clearAnnotationProgress() {
if (annotationProgressBuilder_ == null) {
annotationProgress_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
annotationProgressBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder removeAnnotationProgress(int index) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.remove(index);
onChanged();
} else {
annotationProgressBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder
getAnnotationProgressBuilder(int index) {
return getAnnotationProgressFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgressOrBuilder
getAnnotationProgressOrBuilder(int index) {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.get(index);
} else {
return annotationProgressBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<
? extends com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressOrBuilderList() {
if (annotationProgressBuilder_ != null) {
return annotationProgressBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(annotationProgress_);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder
addAnnotationProgressBuilder() {
return getAnnotationProgressFieldBuilder()
.addBuilder(
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress
.getDefaultInstance());
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder
addAnnotationProgressBuilder(int index) {
return getAnnotationProgressFieldBuilder()
.addBuilder(
index,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress
.getDefaultInstance());
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder>
getAnnotationProgressBuilderList() {
return getAnnotationProgressFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressFieldBuilder() {
if (annotationProgressBuilder_ == null) {
annotationProgressBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p2beta1.VideoAnnotationProgressOrBuilder>(
annotationProgress_,
((bitField0_ & 0x00000001) != 0),
getParentForChildren(),
isClean());
annotationProgress_ = null;
}
return annotationProgressBuilder_;
}
@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.videointelligence.v1p2beta1.AnnotateVideoProgress)
}
// @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress)
private static final com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress();
}
public static com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<AnnotateVideoProgress> PARSER =
new com.google.protobuf.AbstractParser<AnnotateVideoProgress>() {
@java.lang.Override
public AnnotateVideoProgress 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<AnnotateVideoProgress> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<AnnotateVideoProgress> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,352 | java-video-intelligence/proto-google-cloud-video-intelligence-v1p3beta1/src/main/java/com/google/cloud/videointelligence/v1p3beta1/AnnotateVideoProgress.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/videointelligence/v1p3beta1/video_intelligence.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.videointelligence.v1p3beta1;
/**
*
*
* <pre>
* Video annotation progress. Included in the `metadata`
* field of the `Operation` returned by the `GetOperation`
* call of the `google::longrunning::Operations` service.
* </pre>
*
* Protobuf type {@code google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress}
*/
public final class AnnotateVideoProgress extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress)
AnnotateVideoProgressOrBuilder {
private static final long serialVersionUID = 0L;
// Use AnnotateVideoProgress.newBuilder() to construct.
private AnnotateVideoProgress(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private AnnotateVideoProgress() {
annotationProgress_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new AnnotateVideoProgress();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p3beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p3beta1_AnnotateVideoProgress_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress.class,
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress.Builder.class);
}
public static final int ANNOTATION_PROGRESS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress>
annotationProgress_;
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress>
getAnnotationProgressList() {
return annotationProgress_;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public java.util.List<
? extends com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressOrBuilderList() {
return annotationProgress_;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public int getAnnotationProgressCount() {
return annotationProgress_.size();
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress getAnnotationProgress(
int index) {
return annotationProgress_.get(index);
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
@java.lang.Override
public com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgressOrBuilder
getAnnotationProgressOrBuilder(int index) {
return annotationProgress_.get(index);
}
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 {
for (int i = 0; i < annotationProgress_.size(); i++) {
output.writeMessage(1, annotationProgress_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < annotationProgress_.size(); i++) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(1, annotationProgress_.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.videointelligence.v1p3beta1.AnnotateVideoProgress)) {
return super.equals(obj);
}
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress other =
(com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress) obj;
if (!getAnnotationProgressList().equals(other.getAnnotationProgressList())) 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 (getAnnotationProgressCount() > 0) {
hash = (37 * hash) + ANNOTATION_PROGRESS_FIELD_NUMBER;
hash = (53 * hash) + getAnnotationProgressList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress 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.videointelligence.v1p3beta1.AnnotateVideoProgress parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress 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.videointelligence.v1p3beta1.AnnotateVideoProgress parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress 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.videointelligence.v1p3beta1.AnnotateVideoProgress
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress
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.videointelligence.v1p3beta1.AnnotateVideoProgress parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress 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.videointelligence.v1p3beta1.AnnotateVideoProgress 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;
}
/**
*
*
* <pre>
* Video annotation progress. Included in the `metadata`
* field of the `Operation` returned by the `GetOperation`
* call of the `google::longrunning::Operations` service.
* </pre>
*
* Protobuf type {@code google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress)
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgressOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p3beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p3beta1_AnnotateVideoProgress_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress.class,
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress.Builder.class);
}
// Construct using
// com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (annotationProgressBuilder_ == null) {
annotationProgress_ = java.util.Collections.emptyList();
} else {
annotationProgress_ = null;
annotationProgressBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceProto
.internal_static_google_cloud_videointelligence_v1p3beta1_AnnotateVideoProgress_descriptor;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress
getDefaultInstanceForType() {
return com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress
.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress build() {
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress buildPartial() {
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress result =
new com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress result) {
if (annotationProgressBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
annotationProgress_ = java.util.Collections.unmodifiableList(annotationProgress_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.annotationProgress_ = annotationProgress_;
} else {
result.annotationProgress_ = annotationProgressBuilder_.build();
}
}
private void buildPartial0(
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress result) {
int from_bitField0_ = bitField0_;
}
@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.videointelligence.v1p3beta1.AnnotateVideoProgress) {
return mergeFrom(
(com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress other) {
if (other
== com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress
.getDefaultInstance()) return this;
if (annotationProgressBuilder_ == null) {
if (!other.annotationProgress_.isEmpty()) {
if (annotationProgress_.isEmpty()) {
annotationProgress_ = other.annotationProgress_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureAnnotationProgressIsMutable();
annotationProgress_.addAll(other.annotationProgress_);
}
onChanged();
}
} else {
if (!other.annotationProgress_.isEmpty()) {
if (annotationProgressBuilder_.isEmpty()) {
annotationProgressBuilder_.dispose();
annotationProgressBuilder_ = null;
annotationProgress_ = other.annotationProgress_;
bitField0_ = (bitField0_ & ~0x00000001);
annotationProgressBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getAnnotationProgressFieldBuilder()
: null;
} else {
annotationProgressBuilder_.addAllMessages(other.annotationProgress_);
}
}
}
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 10:
{
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress m =
input.readMessage(
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress
.parser(),
extensionRegistry);
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(m);
} else {
annotationProgressBuilder_.addMessage(m);
}
break;
} // case 10
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.videointelligence.v1p3beta1.VideoAnnotationProgress>
annotationProgress_ = java.util.Collections.emptyList();
private void ensureAnnotationProgressIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
annotationProgress_ =
new java.util.ArrayList<
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress>(
annotationProgress_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgressOrBuilder>
annotationProgressBuilder_;
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress>
getAnnotationProgressList() {
if (annotationProgressBuilder_ == null) {
return java.util.Collections.unmodifiableList(annotationProgress_);
} else {
return annotationProgressBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public int getAnnotationProgressCount() {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.size();
} else {
return annotationProgressBuilder_.getCount();
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress
getAnnotationProgress(int index) {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.get(index);
} else {
return annotationProgressBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder setAnnotationProgress(
int index, com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.set(index, value);
onChanged();
} else {
annotationProgressBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder setAnnotationProgress(
int index,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.set(index, builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.add(value);
onChanged();
} else {
annotationProgressBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
int index, com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress value) {
if (annotationProgressBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationProgressIsMutable();
annotationProgress_.add(index, value);
onChanged();
} else {
annotationProgressBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAnnotationProgress(
int index,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder
builderForValue) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.add(index, builderForValue.build());
onChanged();
} else {
annotationProgressBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder addAllAnnotationProgress(
java.lang.Iterable<
? extends com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress>
values) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, annotationProgress_);
onChanged();
} else {
annotationProgressBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder clearAnnotationProgress() {
if (annotationProgressBuilder_ == null) {
annotationProgress_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
annotationProgressBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public Builder removeAnnotationProgress(int index) {
if (annotationProgressBuilder_ == null) {
ensureAnnotationProgressIsMutable();
annotationProgress_.remove(index);
onChanged();
} else {
annotationProgressBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder
getAnnotationProgressBuilder(int index) {
return getAnnotationProgressFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgressOrBuilder
getAnnotationProgressOrBuilder(int index) {
if (annotationProgressBuilder_ == null) {
return annotationProgress_.get(index);
} else {
return annotationProgressBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<
? extends com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressOrBuilderList() {
if (annotationProgressBuilder_ != null) {
return annotationProgressBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(annotationProgress_);
}
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder
addAnnotationProgressBuilder() {
return getAnnotationProgressFieldBuilder()
.addBuilder(
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress
.getDefaultInstance());
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder
addAnnotationProgressBuilder(int index) {
return getAnnotationProgressFieldBuilder()
.addBuilder(
index,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress
.getDefaultInstance());
}
/**
*
*
* <pre>
* Progress metadata for all videos specified in `AnnotateVideoRequest`.
* </pre>
*
* <code>
* repeated .google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress annotation_progress = 1;
* </code>
*/
public java.util.List<
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder>
getAnnotationProgressBuilderList() {
return getAnnotationProgressFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgressOrBuilder>
getAnnotationProgressFieldBuilder() {
if (annotationProgressBuilder_ == null) {
annotationProgressBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgress.Builder,
com.google.cloud.videointelligence.v1p3beta1.VideoAnnotationProgressOrBuilder>(
annotationProgress_,
((bitField0_ & 0x00000001) != 0),
getParentForChildren(),
isClean());
annotationProgress_ = null;
}
return annotationProgressBuilder_;
}
@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.videointelligence.v1p3beta1.AnnotateVideoProgress)
}
// @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress)
private static final com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress();
}
public static com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<AnnotateVideoProgress> PARSER =
new com.google.protobuf.AbstractParser<AnnotateVideoProgress>() {
@java.lang.Override
public AnnotateVideoProgress 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<AnnotateVideoProgress> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<AnnotateVideoProgress> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,430 | java-compute/proto-google-cloud-compute-v1/src/main/java/com/google/cloud/compute/v1/RemoveRuleFirewallPolicyRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/compute/v1/compute.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.compute.v1;
/**
*
*
* <pre>
* A request message for FirewallPolicies.RemoveRule. See the method description for details.
* </pre>
*
* Protobuf type {@code google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest}
*/
public final class RemoveRuleFirewallPolicyRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest)
RemoveRuleFirewallPolicyRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use RemoveRuleFirewallPolicyRequest.newBuilder() to construct.
private RemoveRuleFirewallPolicyRequest(
com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private RemoveRuleFirewallPolicyRequest() {
firewallPolicy_ = "";
requestId_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new RemoveRuleFirewallPolicyRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_RemoveRuleFirewallPolicyRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_RemoveRuleFirewallPolicyRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest.class,
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest.Builder.class);
}
private int bitField0_;
public static final int FIREWALL_POLICY_FIELD_NUMBER = 498173265;
@SuppressWarnings("serial")
private volatile java.lang.Object firewallPolicy_ = "";
/**
*
*
* <pre>
* Name of the firewall policy to update.
* </pre>
*
* <code>string firewall_policy = 498173265 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The firewallPolicy.
*/
@java.lang.Override
public java.lang.String getFirewallPolicy() {
java.lang.Object ref = firewallPolicy_;
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();
firewallPolicy_ = s;
return s;
}
}
/**
*
*
* <pre>
* Name of the firewall policy to update.
* </pre>
*
* <code>string firewall_policy = 498173265 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for firewallPolicy.
*/
@java.lang.Override
public com.google.protobuf.ByteString getFirewallPolicyBytes() {
java.lang.Object ref = firewallPolicy_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
firewallPolicy_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PRIORITY_FIELD_NUMBER = 445151652;
private int priority_ = 0;
/**
*
*
* <pre>
* The priority of the rule to remove from the firewall policy.
* </pre>
*
* <code>optional int32 priority = 445151652;</code>
*
* @return Whether the priority field is set.
*/
@java.lang.Override
public boolean hasPriority() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* The priority of the rule to remove from the firewall policy.
* </pre>
*
* <code>optional int32 priority = 445151652;</code>
*
* @return The priority.
*/
@java.lang.Override
public int getPriority() {
return priority_;
}
public static final int REQUEST_ID_FIELD_NUMBER = 37109963;
@SuppressWarnings("serial")
private volatile java.lang.Object requestId_ = "";
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @return Whether the requestId field is set.
*/
@java.lang.Override
public boolean hasRequestId() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @return The requestId.
*/
@java.lang.Override
public java.lang.String getRequestId() {
java.lang.Object ref = requestId_;
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();
requestId_ = s;
return s;
}
}
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @return The bytes for requestId.
*/
@java.lang.Override
public com.google.protobuf.ByteString getRequestIdBytes() {
java.lang.Object ref = requestId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
requestId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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_ & 0x00000002) != 0)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 37109963, requestId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
output.writeInt32(445151652, priority_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(firewallPolicy_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 498173265, firewallPolicy_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(37109963, requestId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(445151652, priority_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(firewallPolicy_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(498173265, firewallPolicy_);
}
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.RemoveRuleFirewallPolicyRequest)) {
return super.equals(obj);
}
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest other =
(com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest) obj;
if (!getFirewallPolicy().equals(other.getFirewallPolicy())) return false;
if (hasPriority() != other.hasPriority()) return false;
if (hasPriority()) {
if (getPriority() != other.getPriority()) return false;
}
if (hasRequestId() != other.hasRequestId()) return false;
if (hasRequestId()) {
if (!getRequestId().equals(other.getRequestId())) 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();
hash = (37 * hash) + FIREWALL_POLICY_FIELD_NUMBER;
hash = (53 * hash) + getFirewallPolicy().hashCode();
if (hasPriority()) {
hash = (37 * hash) + PRIORITY_FIELD_NUMBER;
hash = (53 * hash) + getPriority();
}
if (hasRequestId()) {
hash = (37 * hash) + REQUEST_ID_FIELD_NUMBER;
hash = (53 * hash) + getRequestId().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest 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.RemoveRuleFirewallPolicyRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest 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.RemoveRuleFirewallPolicyRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest 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.RemoveRuleFirewallPolicyRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest 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.RemoveRuleFirewallPolicyRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest 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.RemoveRuleFirewallPolicyRequest 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.RemoveRuleFirewallPolicyRequest 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.RemoveRuleFirewallPolicyRequest 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;
}
/**
*
*
* <pre>
* A request message for FirewallPolicies.RemoveRule. See the method description for details.
* </pre>
*
* Protobuf type {@code google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest)
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_RemoveRuleFirewallPolicyRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_RemoveRuleFirewallPolicyRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest.class,
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest.Builder.class);
}
// Construct using com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
firewallPolicy_ = "";
priority_ = 0;
requestId_ = "";
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_RemoveRuleFirewallPolicyRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest getDefaultInstanceForType() {
return com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest build() {
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest buildPartial() {
com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest result =
new com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.firewallPolicy_ = firewallPolicy_;
}
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.priority_ = priority_;
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.requestId_ = requestId_;
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.RemoveRuleFirewallPolicyRequest) {
return mergeFrom((com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest other) {
if (other == com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest.getDefaultInstance())
return this;
if (!other.getFirewallPolicy().isEmpty()) {
firewallPolicy_ = other.firewallPolicy_;
bitField0_ |= 0x00000001;
onChanged();
}
if (other.hasPriority()) {
setPriority(other.getPriority());
}
if (other.hasRequestId()) {
requestId_ = other.requestId_;
bitField0_ |= 0x00000004;
onChanged();
}
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 296879706:
{
requestId_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000004;
break;
} // case 296879706
case -733754080:
{
priority_ = input.readInt32();
bitField0_ |= 0x00000002;
break;
} // case -733754080
case -309581174:
{
firewallPolicy_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case -309581174
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.lang.Object firewallPolicy_ = "";
/**
*
*
* <pre>
* Name of the firewall policy to update.
* </pre>
*
* <code>string firewall_policy = 498173265 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The firewallPolicy.
*/
public java.lang.String getFirewallPolicy() {
java.lang.Object ref = firewallPolicy_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
firewallPolicy_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Name of the firewall policy to update.
* </pre>
*
* <code>string firewall_policy = 498173265 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for firewallPolicy.
*/
public com.google.protobuf.ByteString getFirewallPolicyBytes() {
java.lang.Object ref = firewallPolicy_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
firewallPolicy_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Name of the firewall policy to update.
* </pre>
*
* <code>string firewall_policy = 498173265 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The firewallPolicy to set.
* @return This builder for chaining.
*/
public Builder setFirewallPolicy(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
firewallPolicy_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Name of the firewall policy to update.
* </pre>
*
* <code>string firewall_policy = 498173265 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return This builder for chaining.
*/
public Builder clearFirewallPolicy() {
firewallPolicy_ = getDefaultInstance().getFirewallPolicy();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Name of the firewall policy to update.
* </pre>
*
* <code>string firewall_policy = 498173265 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The bytes for firewallPolicy to set.
* @return This builder for chaining.
*/
public Builder setFirewallPolicyBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
firewallPolicy_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private int priority_;
/**
*
*
* <pre>
* The priority of the rule to remove from the firewall policy.
* </pre>
*
* <code>optional int32 priority = 445151652;</code>
*
* @return Whether the priority field is set.
*/
@java.lang.Override
public boolean hasPriority() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* The priority of the rule to remove from the firewall policy.
* </pre>
*
* <code>optional int32 priority = 445151652;</code>
*
* @return The priority.
*/
@java.lang.Override
public int getPriority() {
return priority_;
}
/**
*
*
* <pre>
* The priority of the rule to remove from the firewall policy.
* </pre>
*
* <code>optional int32 priority = 445151652;</code>
*
* @param value The priority to set.
* @return This builder for chaining.
*/
public Builder setPriority(int value) {
priority_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The priority of the rule to remove from the firewall policy.
* </pre>
*
* <code>optional int32 priority = 445151652;</code>
*
* @return This builder for chaining.
*/
public Builder clearPriority() {
bitField0_ = (bitField0_ & ~0x00000002);
priority_ = 0;
onChanged();
return this;
}
private java.lang.Object requestId_ = "";
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @return Whether the requestId field is set.
*/
public boolean hasRequestId() {
return ((bitField0_ & 0x00000004) != 0);
}
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @return The requestId.
*/
public java.lang.String getRequestId() {
java.lang.Object ref = requestId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
requestId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @return The bytes for requestId.
*/
public com.google.protobuf.ByteString getRequestIdBytes() {
java.lang.Object ref = requestId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
requestId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @param value The requestId to set.
* @return This builder for chaining.
*/
public Builder setRequestId(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
requestId_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @return This builder for chaining.
*/
public Builder clearRequestId() {
requestId_ = getDefaultInstance().getRequestId();
bitField0_ = (bitField0_ & ~0x00000004);
onChanged();
return this;
}
/**
*
*
* <pre>
* An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
* </pre>
*
* <code>optional string request_id = 37109963;</code>
*
* @param value The bytes for requestId to set.
* @return This builder for chaining.
*/
public Builder setRequestIdBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
requestId_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
@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.RemoveRuleFirewallPolicyRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest)
private static final com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest();
}
public static com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<RemoveRuleFirewallPolicyRequest> PARSER =
new com.google.protobuf.AbstractParser<RemoveRuleFirewallPolicyRequest>() {
@java.lang.Override
public RemoveRuleFirewallPolicyRequest 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<RemoveRuleFirewallPolicyRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<RemoveRuleFirewallPolicyRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,218 | java-shopping-merchant-accounts/proto-google-shopping-merchant-accounts-v1beta/src/main/java/com/google/shopping/merchant/accounts/v1beta/CreateUserRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/shopping/merchant/accounts/v1beta/user.proto
// Protobuf Java Version: 3.25.8
package com.google.shopping.merchant.accounts.v1beta;
/**
*
*
* <pre>
* Request message for the `CreateUser` method.
* </pre>
*
* Protobuf type {@code google.shopping.merchant.accounts.v1beta.CreateUserRequest}
*/
public final class CreateUserRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.shopping.merchant.accounts.v1beta.CreateUserRequest)
CreateUserRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use CreateUserRequest.newBuilder() to construct.
private CreateUserRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private CreateUserRequest() {
parent_ = "";
userId_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new CreateUserRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.shopping.merchant.accounts.v1beta.UserProto
.internal_static_google_shopping_merchant_accounts_v1beta_CreateUserRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.shopping.merchant.accounts.v1beta.UserProto
.internal_static_google_shopping_merchant_accounts_v1beta_CreateUserRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest.class,
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest.Builder.class);
}
private int bitField0_;
public static final int PARENT_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The resource name of the account for which a user will be
* created. Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The resource name of the account for which a user will be
* created. Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int USER_ID_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object userId_ = "";
/**
*
*
* <pre>
* Required. The email address of the user (for example,
* `john.doe@gmail.com`).
* </pre>
*
* <code>string user_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The userId.
*/
@java.lang.Override
public java.lang.String getUserId() {
java.lang.Object ref = userId_;
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();
userId_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The email address of the user (for example,
* `john.doe@gmail.com`).
* </pre>
*
* <code>string user_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for userId.
*/
@java.lang.Override
public com.google.protobuf.ByteString getUserIdBytes() {
java.lang.Object ref = userId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
userId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int USER_FIELD_NUMBER = 3;
private com.google.shopping.merchant.accounts.v1beta.User user_;
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the user field is set.
*/
@java.lang.Override
public boolean hasUser() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The user.
*/
@java.lang.Override
public com.google.shopping.merchant.accounts.v1beta.User getUser() {
return user_ == null
? com.google.shopping.merchant.accounts.v1beta.User.getDefaultInstance()
: user_;
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.shopping.merchant.accounts.v1beta.UserOrBuilder getUserOrBuilder() {
return user_ == null
? com.google.shopping.merchant.accounts.v1beta.User.getDefaultInstance()
: user_;
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(userId_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, userId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
output.writeMessage(3, getUser());
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(userId_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, userId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getUser());
}
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.shopping.merchant.accounts.v1beta.CreateUserRequest)) {
return super.equals(obj);
}
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest other =
(com.google.shopping.merchant.accounts.v1beta.CreateUserRequest) obj;
if (!getParent().equals(other.getParent())) return false;
if (!getUserId().equals(other.getUserId())) return false;
if (hasUser() != other.hasUser()) return false;
if (hasUser()) {
if (!getUser().equals(other.getUser())) 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();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
hash = (37 * hash) + USER_ID_FIELD_NUMBER;
hash = (53 * hash) + getUserId().hashCode();
if (hasUser()) {
hash = (37 * hash) + USER_FIELD_NUMBER;
hash = (53 * hash) + getUser().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest parseFrom(
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest 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.shopping.merchant.accounts.v1beta.CreateUserRequest parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest 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.shopping.merchant.accounts.v1beta.CreateUserRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest 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.shopping.merchant.accounts.v1beta.CreateUserRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest 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.shopping.merchant.accounts.v1beta.CreateUserRequest 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;
}
/**
*
*
* <pre>
* Request message for the `CreateUser` method.
* </pre>
*
* Protobuf type {@code google.shopping.merchant.accounts.v1beta.CreateUserRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.shopping.merchant.accounts.v1beta.CreateUserRequest)
com.google.shopping.merchant.accounts.v1beta.CreateUserRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.shopping.merchant.accounts.v1beta.UserProto
.internal_static_google_shopping_merchant_accounts_v1beta_CreateUserRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.shopping.merchant.accounts.v1beta.UserProto
.internal_static_google_shopping_merchant_accounts_v1beta_CreateUserRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest.class,
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest.Builder.class);
}
// Construct using com.google.shopping.merchant.accounts.v1beta.CreateUserRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getUserFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
parent_ = "";
userId_ = "";
user_ = null;
if (userBuilder_ != null) {
userBuilder_.dispose();
userBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.shopping.merchant.accounts.v1beta.UserProto
.internal_static_google_shopping_merchant_accounts_v1beta_CreateUserRequest_descriptor;
}
@java.lang.Override
public com.google.shopping.merchant.accounts.v1beta.CreateUserRequest
getDefaultInstanceForType() {
return com.google.shopping.merchant.accounts.v1beta.CreateUserRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.shopping.merchant.accounts.v1beta.CreateUserRequest build() {
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.shopping.merchant.accounts.v1beta.CreateUserRequest buildPartial() {
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest result =
new com.google.shopping.merchant.accounts.v1beta.CreateUserRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.shopping.merchant.accounts.v1beta.CreateUserRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.parent_ = parent_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.userId_ = userId_;
}
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000004) != 0)) {
result.user_ = userBuilder_ == null ? user_ : userBuilder_.build();
to_bitField0_ |= 0x00000001;
}
result.bitField0_ |= to_bitField0_;
}
@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.shopping.merchant.accounts.v1beta.CreateUserRequest) {
return mergeFrom((com.google.shopping.merchant.accounts.v1beta.CreateUserRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.shopping.merchant.accounts.v1beta.CreateUserRequest other) {
if (other
== com.google.shopping.merchant.accounts.v1beta.CreateUserRequest.getDefaultInstance())
return this;
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getUserId().isEmpty()) {
userId_ = other.userId_;
bitField0_ |= 0x00000002;
onChanged();
}
if (other.hasUser()) {
mergeUser(other.getUser());
}
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 10:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
userId_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 26:
{
input.readMessage(getUserFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000004;
break;
} // case 26
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.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The resource name of the account for which a user will be
* created. Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The resource name of the account for which a user will be
* created. Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The resource name of the account for which a user will be
* created. Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource name of the account for which a user will be
* created. Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource name of the account for which a user will be
* created. Format: `accounts/{account}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object userId_ = "";
/**
*
*
* <pre>
* Required. The email address of the user (for example,
* `john.doe@gmail.com`).
* </pre>
*
* <code>string user_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The userId.
*/
public java.lang.String getUserId() {
java.lang.Object ref = userId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
userId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The email address of the user (for example,
* `john.doe@gmail.com`).
* </pre>
*
* <code>string user_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for userId.
*/
public com.google.protobuf.ByteString getUserIdBytes() {
java.lang.Object ref = userId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
userId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The email address of the user (for example,
* `john.doe@gmail.com`).
* </pre>
*
* <code>string user_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The userId to set.
* @return This builder for chaining.
*/
public Builder setUserId(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
userId_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The email address of the user (for example,
* `john.doe@gmail.com`).
* </pre>
*
* <code>string user_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return This builder for chaining.
*/
public Builder clearUserId() {
userId_ = getDefaultInstance().getUserId();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The email address of the user (for example,
* `john.doe@gmail.com`).
* </pre>
*
* <code>string user_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The bytes for userId to set.
* @return This builder for chaining.
*/
public Builder setUserIdBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
userId_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private com.google.shopping.merchant.accounts.v1beta.User user_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.shopping.merchant.accounts.v1beta.User,
com.google.shopping.merchant.accounts.v1beta.User.Builder,
com.google.shopping.merchant.accounts.v1beta.UserOrBuilder>
userBuilder_;
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the user field is set.
*/
public boolean hasUser() {
return ((bitField0_ & 0x00000004) != 0);
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The user.
*/
public com.google.shopping.merchant.accounts.v1beta.User getUser() {
if (userBuilder_ == null) {
return user_ == null
? com.google.shopping.merchant.accounts.v1beta.User.getDefaultInstance()
: user_;
} else {
return userBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUser(com.google.shopping.merchant.accounts.v1beta.User value) {
if (userBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
user_ = value;
} else {
userBuilder_.setMessage(value);
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUser(
com.google.shopping.merchant.accounts.v1beta.User.Builder builderForValue) {
if (userBuilder_ == null) {
user_ = builderForValue.build();
} else {
userBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeUser(com.google.shopping.merchant.accounts.v1beta.User value) {
if (userBuilder_ == null) {
if (((bitField0_ & 0x00000004) != 0)
&& user_ != null
&& user_ != com.google.shopping.merchant.accounts.v1beta.User.getDefaultInstance()) {
getUserBuilder().mergeFrom(value);
} else {
user_ = value;
}
} else {
userBuilder_.mergeFrom(value);
}
if (user_ != null) {
bitField0_ |= 0x00000004;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearUser() {
bitField0_ = (bitField0_ & ~0x00000004);
user_ = null;
if (userBuilder_ != null) {
userBuilder_.dispose();
userBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.shopping.merchant.accounts.v1beta.User.Builder getUserBuilder() {
bitField0_ |= 0x00000004;
onChanged();
return getUserFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.shopping.merchant.accounts.v1beta.UserOrBuilder getUserOrBuilder() {
if (userBuilder_ != null) {
return userBuilder_.getMessageOrBuilder();
} else {
return user_ == null
? com.google.shopping.merchant.accounts.v1beta.User.getDefaultInstance()
: user_;
}
}
/**
*
*
* <pre>
* Required. The user to create.
* </pre>
*
* <code>
* .google.shopping.merchant.accounts.v1beta.User user = 3 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.shopping.merchant.accounts.v1beta.User,
com.google.shopping.merchant.accounts.v1beta.User.Builder,
com.google.shopping.merchant.accounts.v1beta.UserOrBuilder>
getUserFieldBuilder() {
if (userBuilder_ == null) {
userBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.shopping.merchant.accounts.v1beta.User,
com.google.shopping.merchant.accounts.v1beta.User.Builder,
com.google.shopping.merchant.accounts.v1beta.UserOrBuilder>(
getUser(), getParentForChildren(), isClean());
user_ = null;
}
return userBuilder_;
}
@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.shopping.merchant.accounts.v1beta.CreateUserRequest)
}
// @@protoc_insertion_point(class_scope:google.shopping.merchant.accounts.v1beta.CreateUserRequest)
private static final com.google.shopping.merchant.accounts.v1beta.CreateUserRequest
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.shopping.merchant.accounts.v1beta.CreateUserRequest();
}
public static com.google.shopping.merchant.accounts.v1beta.CreateUserRequest
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<CreateUserRequest> PARSER =
new com.google.protobuf.AbstractParser<CreateUserRequest>() {
@java.lang.Override
public CreateUserRequest 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<CreateUserRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<CreateUserRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.shopping.merchant.accounts.v1beta.CreateUserRequest
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/gobblin | 36,488 | gobblin-metrics-libs/gobblin-metrics/src/main/java/org/apache/gobblin/metrics/GobblinMetrics.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.gobblin.metrics;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.jmx.JmxReporter;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.io.Closer;
import com.typesafe.config.Config;
import lombok.Getter;
import org.apache.gobblin.configuration.ConfigurationKeys;
import org.apache.gobblin.configuration.State;
import org.apache.gobblin.metrics.graphite.GraphiteConnectionType;
import org.apache.gobblin.metrics.graphite.GraphiteEventReporter;
import org.apache.gobblin.metrics.graphite.GraphiteReporter;
import org.apache.gobblin.metrics.influxdb.InfluxDBConnectionType;
import org.apache.gobblin.metrics.influxdb.InfluxDBEventReporter;
import org.apache.gobblin.metrics.influxdb.InfluxDBReporter;
import org.apache.gobblin.metrics.reporter.FileFailureEventReporter;
import org.apache.gobblin.metrics.reporter.OutputStreamEventReporter;
import org.apache.gobblin.metrics.reporter.OutputStreamReporter;
import org.apache.gobblin.metrics.reporter.ScheduledReporter;
import org.apache.gobblin.password.PasswordManager;
import org.apache.gobblin.util.PropertiesUtils;
/**
* A class that represents a set of metrics associated with a given name.
*
* @author Yinan Li
*/
public class GobblinMetrics {
public static final String METRICS_ID_PREFIX = "gobblin.metrics.";
public static final String METRICS_STATE_CUSTOM_TAGS = "metrics.state.custom.tags";
@Getter
protected static final GobblinMetricsRegistry GOBBLIN_METRICS_REGISTRY = GobblinMetricsRegistry.getInstance();
/**
* Enumeration of metric types.
*/
public enum MetricType {
COUNTER, METER, GAUGE
}
private static final Logger LOGGER = LoggerFactory.getLogger(GobblinMetrics.class);
/**
* Check whether metrics collection and reporting are enabled or not.
*
* @param properties Configuration properties
* @return whether metrics collection and reporting are enabled
*/
public static boolean isEnabled(Properties properties) {
return PropertiesUtils
.getPropAsBoolean(properties, ConfigurationKeys.METRICS_ENABLED_KEY, ConfigurationKeys.DEFAULT_METRICS_ENABLED);
}
/**
* Check whether metrics collection and reporting are enabled or not.
*
* @param state a {@link State} object containing configuration properties
* @return whether metrics collection and reporting are enabled
*/
public static boolean isEnabled(State state) {
return Boolean
.valueOf(state.getProp(ConfigurationKeys.METRICS_ENABLED_KEY, ConfigurationKeys.DEFAULT_METRICS_ENABLED));
}
/**
* Check whether metrics collection and reporting are enabled or not.
*
* @param cfg a {@link State} object containing configuration properties
* @return whether metrics collection and reporting are enabled
*/
public static boolean isEnabled(Config cfg) {
return cfg.hasPath(ConfigurationKeys.METRICS_ENABLED_KEY) ? cfg.getBoolean(ConfigurationKeys.METRICS_ENABLED_KEY)
: Boolean.parseBoolean(ConfigurationKeys.DEFAULT_METRICS_ENABLED);
}
/**
* Get a {@link GobblinMetrics} instance with the given ID.
*
* @param id the given {@link GobblinMetrics} ID
* @return a {@link GobblinMetrics} instance
*/
public static GobblinMetrics get(String id) {
return get(id, null);
}
/**
* Get a {@link GobblinMetrics} instance with the given ID and parent {@link MetricContext}.
*
* @param id the given {@link GobblinMetrics} ID
* @param parentContext the given parent {@link MetricContext}
* @return a {@link GobblinMetrics} instance
*/
public static GobblinMetrics get(String id, MetricContext parentContext) {
return get(id, parentContext, Lists.<Tag<?>>newArrayList());
}
/**
* Get a {@link GobblinMetrics} instance with the given ID, parent {@link MetricContext},
* and list of {@link Tag}s.
*
* @param id the given {@link GobblinMetrics} ID
* @param parentContext the given parent {@link MetricContext}
* @param tags the given list of {@link Tag}s
* @return a {@link GobblinMetrics} instance
*/
public static GobblinMetrics get(final String id, final MetricContext parentContext, final List<Tag<?>> tags) {
return GOBBLIN_METRICS_REGISTRY.getOrCreate(id, new Callable<GobblinMetrics>() {
@Override
public GobblinMetrics call()
throws Exception {
return new GobblinMetrics(id, parentContext, tags);
}
});
}
/**
* Remove the {@link GobblinMetrics} instance associated with the given ID.
*
* @param id the given {@link GobblinMetrics} ID
*/
public static void remove(String id) {
GOBBLIN_METRICS_REGISTRY.remove(id);
}
/**
* Add a {@link List} of {@link Tag}s to a {@link org.apache.gobblin.configuration.State} with key {@link #METRICS_STATE_CUSTOM_TAGS}.
*
* <p>
* {@link org.apache.gobblin.metrics.Tag}s under this key can later be parsed using the method {@link #getCustomTagsFromState}.
* </p>
*
* @param state {@link org.apache.gobblin.configuration.State} state to add the tag to.
* @param tags list of {@link Tag}s to add.
*/
public static void addCustomTagToState(State state, List<? extends Tag<?>> tags) {
for (Tag<?> tag : tags) {
state.appendToListProp(METRICS_STATE_CUSTOM_TAGS, tag.toString());
}
}
/**
* Add a {@link Tag} to a {@link org.apache.gobblin.configuration.State} with key {@link #METRICS_STATE_CUSTOM_TAGS}.
*
* <p>
* {@link org.apache.gobblin.metrics.Tag}s under this key can later be parsed using the method {@link #getCustomTagsFromState}.
* </p>
*
* @param state {@link org.apache.gobblin.configuration.State} state to add the tag to.
* @param tag {@link Tag} to add.
*/
public static void addCustomTagToState(State state, Tag<?> tag) {
state.appendToListProp(METRICS_STATE_CUSTOM_TAGS, tag.toString());
}
/**
* Add {@link List} of {@link Tag}s to a {@link Properties} with key {@link #METRICS_STATE_CUSTOM_TAGS}.
* <p>
* Also see {@link #addCustomTagToState(State, Tag)} , {@link #addCustomTagToProperties(Properties, Tag)}
* </p>
*
* <p>
* The {@link Properties} passed can be used to build a {@link State}.
* {@link org.apache.gobblin.metrics.Tag}s under this key can later be parsed using the method {@link #getCustomTagsFromState}.
* </p>
*
* @param properties {@link Properties} to add the tag to.
* @param tags list of {@link Tag}s to add.
*/
public static void addCustomTagsToProperties(Properties properties, List<Tag<?>> tags) {
for (Tag<?> tag : tags) {
addCustomTagToProperties(properties, tag);
}
}
/**
* Add a {@link Tag} to a {@link Properties} with key {@link #METRICS_STATE_CUSTOM_TAGS}.
* Also see {@link #addCustomTagToState(State, Tag)}
*
* <p>
* The {@link Properties} passed can be used to build a {@link State}.
* {@link org.apache.gobblin.metrics.Tag}s under this key can later be parsed using the method {@link #getCustomTagsFromState}.
* </p>
*
* @param properties {@link Properties} to add the tag to.
* @param tag {@link Tag} to add.
*/
public static void addCustomTagToProperties(Properties properties, Tag<?> tag) {
// Build a state wrapper to add custom tag to property
State state = new State(properties);
addCustomTagToState(state, tag);
}
/**
* Parse custom {@link org.apache.gobblin.metrics.Tag}s from property {@link #METRICS_STATE_CUSTOM_TAGS}
* in the input {@link org.apache.gobblin.configuration.State}.
* @param state {@link org.apache.gobblin.configuration.State} possibly containing custom tags.
* @return List of {@link org.apache.gobblin.metrics.Tag} parsed from input.
*/
public static List<Tag<?>> getCustomTagsFromState(State state) {
List<Tag<?>> tags = Lists.newArrayList();
for (String tagKeyValue : state.getPropAsList(METRICS_STATE_CUSTOM_TAGS, "")) {
Tag<?> tag = Tag.fromString(tagKeyValue);
if (tag != null) {
tags.add(tag);
}
}
return tags;
}
protected final String id;
protected final MetricContext metricContext;
// Closer for closing the metric output stream
protected final Closer codahaleReportersCloser = Closer.create();
// JMX metric reporter
private Optional<JmxReporter> jmxReporter = Optional.absent();
// Custom metric reporters instantiated through reflection
private final List<com.codahale.metrics.ScheduledReporter> codahaleScheduledReporters = Lists.newArrayList();
// A flag telling whether metric reporting has started or not
private volatile boolean metricsReportingStarted = false;
protected GobblinMetrics(String id, MetricContext parentContext, List<Tag<?>> tags) {
this.id = id;
this.metricContext = parentContext == null ? new MetricContext.Builder(id).addTags(tags).build()
: parentContext.childBuilder(id).addTags(tags).build();
}
/**
* Get the wrapped {@link com.codahale.metrics.MetricRegistry} instance.
*
* @return wrapped {@link com.codahale.metrics.MetricRegistry} instance
*/
public MetricContext getMetricContext() {
return this.metricContext;
}
/**
* Get the ID of this {@link GobblinMetrics}.
*
* @return ID of this {@link GobblinMetrics}
*/
public String getId() {
return this.id;
}
/**
* Get the name of this {@link GobblinMetrics}.
*
* <p>
* This method is currently equivalent to {@link #getId()}.
* </p>
*
* @return name of this {@link GobblinMetrics}
*/
public String getName() {
return this.id;
}
/**
* Get a {@link Meter} with the given name prefix and suffixes.
*
* @param prefix the given name prefix
* @param suffixes the given name suffixes
* @return a {@link Meter} with the given name prefix and suffixes
*/
public Meter getMeter(String prefix, String... suffixes) {
return this.metricContext.meter(MetricRegistry.name(prefix, suffixes));
}
/**
* Get a {@link Counter} with the given name prefix and suffixes.
*
* @param prefix the given name prefix
* @param suffixes the given name suffixes
* @return a {@link Counter} with the given name prefix and suffixes
*/
public Counter getCounter(String prefix, String... suffixes) {
return this.metricContext.counter(MetricRegistry.name(prefix, suffixes));
}
/**
* Get a {@link Histogram} with the given name prefix and suffixes.
*
* @param prefix the given name prefix
* @param suffixes the given name suffixes
* @return a {@link Histogram} with the given name prefix and suffixes
*/
public Histogram getHistogram(String prefix, String... suffixes) {
return this.metricContext.histogram(MetricRegistry.name(prefix, suffixes));
}
/**
* Get a {@link Timer} with the given name prefix and suffixes.
*
* @param prefix the given name prefix
* @param suffixes the given name suffixes
* @return a {@link Timer} with the given name prefix and suffixes
*/
public Timer getTimer(String prefix, String... suffixes) {
return this.metricContext.timer(MetricRegistry.name(prefix, suffixes));
}
/**
* Starts metric reporting and appends the given metrics file suffix to the current value of
* {@link ConfigurationKeys#METRICS_FILE_SUFFIX}.
*/
public void startMetricReportingWithFileSuffix(State state, String metricsFileSuffix)
throws MultiReporterException {
Properties metricsReportingProps = new Properties();
metricsReportingProps.putAll(state.getProperties());
String oldMetricsFileSuffix =
state.getProp(ConfigurationKeys.METRICS_FILE_SUFFIX, ConfigurationKeys.DEFAULT_METRICS_FILE_SUFFIX);
if (Strings.isNullOrEmpty(oldMetricsFileSuffix)) {
oldMetricsFileSuffix = metricsFileSuffix;
} else {
oldMetricsFileSuffix += "." + metricsFileSuffix;
}
metricsReportingProps.setProperty(ConfigurationKeys.METRICS_FILE_SUFFIX, oldMetricsFileSuffix);
startMetricReporting(metricsReportingProps);
}
/**
* Start metric reporting.
*
* @param configuration configuration properties
*/
public void startMetricReporting(Configuration configuration)
throws MultiReporterException {
Properties props = new Properties();
for (Map.Entry<String, String> entry : configuration) {
props.put(entry.getKey(), entry.getValue());
}
startMetricReporting(props);
}
/**
* Start metric reporting.
*
* @param properties configuration properties
*/
public void startMetricReporting(Properties properties) throws MultiReporterException {
if (this.metricsReportingStarted) {
LOGGER.warn("Metric reporting has already started");
return;
}
TimeUnit reportTimeUnit = TimeUnit.MILLISECONDS;
long reportInterval = Long.parseLong(properties
.getProperty(ConfigurationKeys.METRICS_REPORT_INTERVAL_KEY, ConfigurationKeys.DEFAULT_METRICS_REPORT_INTERVAL));
ScheduledReporter.setReportingInterval(properties, reportInterval, reportTimeUnit);
long startTime = System.currentTimeMillis();
List<MetricReporterException> reporterExceptions = Lists.newArrayList();
try {
for (ReporterSinkType sinkType: ReporterSinkType.values()) {
if (sinkType.equals(ReporterSinkType.CUSTOM)) {
buildCustomMetricReporters(properties, reporterExceptions);
} else {
try {
buildReporter(properties, sinkType);
} catch (MultiReporterException e) {
reporterExceptions.addAll(e.getExceptions());
}
}
}
// Start reporters that implement org.apache.gobblin.metrics.report.ScheduledReporter
RootMetricContext.get().startReporting();
// Start reporters that implement com.codahale.metrics.ScheduledReporter
for (com.codahale.metrics.ScheduledReporter scheduledReporter : this.codahaleScheduledReporters) {
scheduledReporter.start(reportInterval, reportTimeUnit);
}
} catch (Exception e) {
LOGGER.error("Metrics reporting cannot be started due to {}", ExceptionUtils.getFullStackTrace(e));
throw e;
}
this.metricsReportingStarted = true;
LOGGER.info("Metrics reporting has been started in {} ms: GobblinMetrics {}",
System.currentTimeMillis() - startTime, this.toString());
if (!reporterExceptions.isEmpty()) {
throw new MultiReporterException("Could not create one or more reporters", reporterExceptions);
}
}
private void buildReporter(Properties properties, ReporterSinkType sinkType) throws MultiReporterException {
switch (sinkType) {
case JMX:
buildJmxMetricReporter(properties);
break;
case FILE:
buildFileMetricReporter(properties);
break;
case KAFKA:
buildKafkaMetricReporter(properties);
break;
case GRAPHITE:
buildGraphiteMetricReporter(properties);
break;
case INFLUXDB:
buildInfluxDBMetricReporter(properties);
break;
case FILE_FAILURE:
buildFileFailureEventReporter(properties);
break;
default:
LOGGER.error("Unknown reporter sink type: {}", sinkType.name());
break;
}
}
/**
* Stop metric reporting.
*/
public void stopMetricsReporting() {
LOGGER.info("Metrics reporting will be stopped: GobblinMetrics {}", this.toString());
if (!this.metricsReportingStarted) {
LOGGER.warn("Metric reporting has not started yet");
return;
}
// Stop the JMX reporter
if (this.jmxReporter.isPresent()) {
this.jmxReporter.get().stop();
}
// Trigger and stop reporters that implement org.apache.gobblin.metrics.report.ScheduledReporter
RootMetricContext.get().stopReporting();
// Trigger and stop reporters that implement com.codahale.metrics.ScheduledReporter
for (com.codahale.metrics.ScheduledReporter scheduledReporter : this.codahaleScheduledReporters) {
scheduledReporter.report();
}
try {
this.codahaleReportersCloser.close();
} catch (IOException ioe) {
LOGGER.error("Failed to close metric output stream for job " + this.id, ioe);
} catch (Exception e) {
LOGGER.error("Failed to close metric output stream for job {} due to {}", this.id, ExceptionUtils.getFullStackTrace(e));
throw e;
}
this.metricsReportingStarted = false;
// Remove from the cache registry
GobblinMetrics.remove(id);
LOGGER.info("Metrics reporting stopped successfully");
}
private void buildFileMetricReporter(Properties properties)
throws MultiReporterException {
if (!Boolean.valueOf(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_FILE_ENABLED_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_FILE_ENABLED))) {
return;
}
LOGGER.info("Reporting metrics to log files");
if (!properties.containsKey(ConfigurationKeys.METRICS_LOG_DIR_KEY)) {
MetricReporterException e = new MetricReporterException(
"Not reporting metrics to log files because " + ConfigurationKeys.METRICS_LOG_DIR_KEY + " is undefined", ReporterType.METRIC, ReporterSinkType.FILE);
throw new MultiReporterException("Failed to create file metric reporter", Lists.newArrayList(e));
}
try {
String fsUri = properties.getProperty(ConfigurationKeys.FS_URI_KEY, ConfigurationKeys.LOCAL_FS_URI);
FileSystem fs = FileSystem.get(URI.create(fsUri), new Configuration());
// Each job gets its own metric log subdirectory
Path metricsLogDir = new Path(properties.getProperty(ConfigurationKeys.METRICS_LOG_DIR_KEY), this.getName());
if (!fs.exists(metricsLogDir) && !fs.mkdirs(metricsLogDir)) {
throw new MetricReporterException("Failed to create metric log directory for metrics " + this.getName(), ReporterType.METRIC, ReporterSinkType.FILE);
}
// Add a suffix to file name if specified in properties.
String metricsFileSuffix =
properties.getProperty(ConfigurationKeys.METRICS_FILE_SUFFIX, ConfigurationKeys.DEFAULT_METRICS_FILE_SUFFIX);
if (!Strings.isNullOrEmpty(metricsFileSuffix) && !metricsFileSuffix.startsWith(".")) {
metricsFileSuffix = "." + metricsFileSuffix;
}
// Each job run gets its own metric log file
Path metricLogFile =
new Path(metricsLogDir, this.id + metricsFileSuffix + ".metrics.log");
boolean append = false;
// Append to the metric file if it already exists
if (fs.exists(metricLogFile)) {
LOGGER.info(String.format("Metric log file %s already exists, appending to it", metricLogFile));
append = true;
}
OutputStream output = append ? fs.append(metricLogFile) : fs.create(metricLogFile, true);
// Add metrics reporter
OutputStreamReporter.Factory.newBuilder().outputTo(output).build(properties);
// Set up events reporter at the same time!!
this.codahaleScheduledReporters.add(this.codahaleReportersCloser
.register(OutputStreamEventReporter.forContext(RootMetricContext.get()).outputTo(output).build()));
LOGGER.info("Will start reporting metrics to directory " + metricsLogDir);
} catch (IOException ioe) {
MetricReporterException e = new MetricReporterException("Failed to build file metric reporter for job " + this.id, ioe, ReporterType.METRIC, ReporterSinkType.FILE);
throw new MultiReporterException("Failed to create file metric reporter", Lists.newArrayList(e));
}
}
private void buildFileFailureEventReporter(Properties properties)
throws MultiReporterException {
if ((!Boolean.valueOf(properties.getProperty(ConfigurationKeys.FAILURE_REPORTING_FILE_ENABLED_KEY,
ConfigurationKeys.DEFAULT_FAILURE_REPORTING_FILE_ENABLED)) || !properties.containsKey(ConfigurationKeys.FAILURE_LOG_DIR_KEY))) {
return;
}
LOGGER.info("Reporting failure to log files");
try {
String fsUri = properties.getProperty(ConfigurationKeys.FS_URI_KEY, ConfigurationKeys.LOCAL_FS_URI);
FileSystem fs = FileSystem.get(URI.create(fsUri), new Configuration());
// Each job gets its own log subdirectory
Path failureLogDir = new Path(properties.getProperty(ConfigurationKeys.FAILURE_LOG_DIR_KEY), this.getName());
if (!fs.exists(failureLogDir) && !fs.mkdirs(failureLogDir)) {
throw new MetricReporterException("Failed to create failure log directory for metrics " + this.getName(), ReporterType.EVENT, ReporterSinkType.FILE);
}
// Add a suffix to file name if specified in properties.
String metricsFileSuffix =
properties.getProperty(ConfigurationKeys.METRICS_FILE_SUFFIX, ConfigurationKeys.DEFAULT_METRICS_FILE_SUFFIX);
if (!Strings.isNullOrEmpty(metricsFileSuffix) && !metricsFileSuffix.startsWith(".")) {
metricsFileSuffix = "." + metricsFileSuffix;
}
// Each job run gets its own failure log file
Path failureLogFile =
new Path(failureLogDir, this.id + metricsFileSuffix + ".failure.log");
this.codahaleScheduledReporters.add(this.codahaleReportersCloser
.register(new FileFailureEventReporter(RootMetricContext.get(), fs, failureLogFile)));
LOGGER.info("Will start reporting failure to directory " + failureLogDir);
} catch (IOException ioe) {
MetricReporterException e = new MetricReporterException("Failed to build file failure event reporter for job " + this.id, ioe, ReporterType.EVENT, ReporterSinkType.FILE);
throw new MultiReporterException("Failed to create failure file event reporter", Lists.newArrayList(e));
}
}
private void buildJmxMetricReporter(Properties properties) {
if (!Boolean.valueOf(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_JMX_ENABLED_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_JMX_ENABLED))) {
return;
}
LOGGER.info("Reporting metrics to JMX");
this.jmxReporter = Optional.of(codahaleReportersCloser.register(JmxReporter.forRegistry(RootMetricContext.get()).
convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build()));
}
private void buildKafkaMetricReporter(Properties properties)
throws MultiReporterException {
List<MetricReporterException> reporterExceptions = Lists.newArrayList();
if (!Boolean.parseBoolean(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_KAFKA_ENABLED_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_KAFKA_ENABLED))) {
return;
}
if (Boolean.parseBoolean(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_KAFKA_METRICS_ENABLED_KEY,
Boolean.toString(true)))) {
try {
buildScheduledReporter(properties, ConfigurationKeys.DEFAULT_METRICS_REPORTING_KAFKA_REPORTER_CLASS);
} catch (MetricReporterException e) {
reporterExceptions.add(e);
}
}
if (Boolean.parseBoolean(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_KAFKA_EVENTS_ENABLED_KEY,
Boolean.toString(true)))) {
try {
buildScheduledReporter(properties, ConfigurationKeys.DEFAULT_EVENTS_REPORTING_KAFKA_REPORTER_CLASS);
} catch (MetricReporterException e) {
reporterExceptions.add(e);
}
}
if (!reporterExceptions.isEmpty()) {
throw new MultiReporterException("Failed to start one or more Kafka reporters", reporterExceptions);
}
}
private void buildGraphiteMetricReporter(Properties properties)
throws MultiReporterException {
List<MetricReporterException> reporterExceptionList = Lists.newArrayList();
boolean metricsEnabled = PropertiesUtils
.getPropAsBoolean(properties, ConfigurationKeys.METRICS_REPORTING_GRAPHITE_METRICS_ENABLED_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_GRAPHITE_METRICS_ENABLED);
if (metricsEnabled) {
LOGGER.info("Reporting metrics to Graphite");
}
boolean eventsEnabled = PropertiesUtils
.getPropAsBoolean(properties, ConfigurationKeys.METRICS_REPORTING_GRAPHITE_EVENTS_ENABLED_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_GRAPHITE_EVENTS_ENABLED);
if (eventsEnabled) {
LOGGER.info("Reporting events to Graphite");
}
if (!metricsEnabled && !eventsEnabled) {
return;
}
try {
Preconditions.checkArgument(properties.containsKey(ConfigurationKeys.METRICS_REPORTING_GRAPHITE_HOSTNAME),
"Graphite hostname is missing.");
} catch (IllegalArgumentException exception) {
reporterExceptionList.add(new MetricReporterException("Missing Graphite configuration(s).", exception, ReporterType.METRIC_EVENT, ReporterSinkType.GRAPHITE));
throw new MultiReporterException("Failed to start one or more Graphite reporters", reporterExceptionList);
}
String hostname = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_GRAPHITE_HOSTNAME);
int port = Integer.parseInt(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_GRAPHITE_PORT,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_GRAPHITE_PORT));
GraphiteConnectionType connectionType;
String type = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_GRAPHITE_SENDING_TYPE,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_GRAPHITE_SENDING_TYPE).toUpperCase();
String prefix = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_GRAPHITE_PREFIX,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_GRAPHITE_PREFIX);
try {
connectionType = GraphiteConnectionType.valueOf(type);
} catch (IllegalArgumentException exception) {
LOGGER
.warn("Graphite Reporter connection type " + type + " not recognized. Will use TCP for sending.", exception);
connectionType = GraphiteConnectionType.TCP;
}
if (metricsEnabled) {
try {
GraphiteReporter.Factory.newBuilder().withConnectionType(connectionType)
.withConnection(hostname, port).withMetricContextName(
this.metricContext.getName()) //contains the current job id
.withMetricsPrefix(prefix)
.build(properties);
} catch (IOException e) {
reporterExceptionList.add(new MetricReporterException("Failed to create Graphite metrics reporter.", e, ReporterType.METRIC, ReporterSinkType.GRAPHITE));
}
}
if (eventsEnabled) {
boolean emitValueAsKey = PropertiesUtils
.getPropAsBoolean(properties, ConfigurationKeys.METRICS_REPORTING_GRAPHITE_EVENTS_VALUE_AS_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_GRAPHITE_EVENTS_VALUE_AS_KEY);
String eventsPortProp = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_GRAPHITE_EVENTS_PORT);
int eventsPort = (eventsPortProp == null) ? (metricsEnabled ? port
: Integer.parseInt(ConfigurationKeys.METRICS_REPORTING_GRAPHITE_PORT)) : Integer.parseInt(eventsPortProp);
try {
GraphiteEventReporter eventReporter =
GraphiteEventReporter.Factory.forContext(RootMetricContext.get())
.withConnectionType(connectionType)
.withConnection(hostname, eventsPort)
.withPrefix(prefix)
.withEmitValueAsKey(emitValueAsKey)
.build();
this.codahaleScheduledReporters.add(this.codahaleReportersCloser.register(eventReporter));
}
catch (IOException e) {
reporterExceptionList.add(new MetricReporterException("Failed to create Graphite event reporter.", e, ReporterType.EVENT, ReporterSinkType.GRAPHITE));
}
}
if (!reporterExceptionList.isEmpty()) {
throw new MultiReporterException("Failed to create one or more Graphite Reporters", reporterExceptionList);
}
}
private void buildInfluxDBMetricReporter(Properties properties)
throws MultiReporterException {
List<MetricReporterException> reporterExceptionList = Lists.newArrayList();
boolean metricsEnabled = PropertiesUtils
.getPropAsBoolean(properties, ConfigurationKeys.METRICS_REPORTING_INFLUXDB_METRICS_ENABLED_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_INFLUXDB_METRICS_ENABLED);
if (metricsEnabled) {
LOGGER.info("Reporting metrics to InfluxDB");
}
boolean eventsEnabled = PropertiesUtils
.getPropAsBoolean(properties, ConfigurationKeys.METRICS_REPORTING_INFLUXDB_EVENTS_ENABLED_KEY,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_INFLUXDB_EVENTS_ENABLED);
if (eventsEnabled) {
LOGGER.info("Reporting events to InfluxDB");
}
if (!metricsEnabled && !eventsEnabled) {
return;
}
try {
Preconditions.checkArgument(properties.containsKey(ConfigurationKeys.METRICS_REPORTING_INFLUXDB_DATABASE),
"InfluxDB database name is missing.");
} catch (IllegalArgumentException exception) {
reporterExceptionList.add(new MetricReporterException("Missing InfluxDB configuration(s)", exception, ReporterType.METRIC_EVENT, ReporterSinkType.INFLUXDB));
throw new MultiReporterException("Failed to start one or more InfluxDB reporters", reporterExceptionList);
}
String url = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_INFLUXDB_URL);
String username = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_INFLUXDB_USER);
String password = PasswordManager.getInstance(properties)
.readPassword(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_INFLUXDB_PASSWORD));
String database = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_INFLUXDB_DATABASE);
InfluxDBConnectionType connectionType;
String type = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_INFLUXDB_SENDING_TYPE,
ConfigurationKeys.DEFAULT_METRICS_REPORTING_INFLUXDB_SENDING_TYPE).toUpperCase();
try {
connectionType = InfluxDBConnectionType.valueOf(type);
} catch (IllegalArgumentException exception) {
LOGGER
.warn("InfluxDB Reporter connection type " + type + " not recognized. Will use TCP for sending.", exception);
connectionType = InfluxDBConnectionType.TCP;
}
if (metricsEnabled) {
try {
InfluxDBReporter.Factory.newBuilder().withConnectionType(connectionType)
.withConnection(url, username, password, database).withMetricContextName(
this.metricContext.getName()) // contains the current job id
.build(properties);
} catch (IOException e) {
reporterExceptionList.add(new MetricReporterException("Failed to create InfluxDB metrics reporter.", e, ReporterType.METRIC, ReporterSinkType.INFLUXDB));
}
}
if (eventsEnabled) {
String eventsDbProp = properties.getProperty(ConfigurationKeys.METRICS_REPORTING_INFLUXDB_EVENTS_DATABASE);
String eventsDatabase = (eventsDbProp == null) ? (metricsEnabled ? database : null) : eventsDbProp;
try {
InfluxDBEventReporter eventReporter =
InfluxDBEventReporter.Factory.forContext(RootMetricContext.get())
.withConnectionType(connectionType)
.withConnection(url, username, password, eventsDatabase)
.build();
this.codahaleScheduledReporters.add(this.codahaleReportersCloser.register(eventReporter));
}
catch (IOException e) {
reporterExceptionList.add(new MetricReporterException("Failed to create InfluxDB event reporter.", e, ReporterType.EVENT, ReporterSinkType.INFLUXDB));
}
}
if (!reporterExceptionList.isEmpty()) {
throw new MultiReporterException("Failed to create one or more InfluxDB reporters", reporterExceptionList);
}
}
/**
* Build scheduled metrics reporters by reflection from the property
* {@link org.apache.gobblin.configuration.ConfigurationKeys#METRICS_CUSTOM_BUILDERS}. This allows users to specify custom
* reporters for Gobblin runtime without having to modify the code.
*/
private void buildCustomMetricReporters(Properties properties, List<MetricReporterException> reporterExceptions) {
String reporterClasses = properties.getProperty(ConfigurationKeys.METRICS_CUSTOM_BUILDERS);
if (Strings.isNullOrEmpty(reporterClasses)) {
return;
}
for (String reporterClass : Splitter.on(",").split(reporterClasses)) {
try {
buildScheduledReporter(properties, reporterClass);
} catch (MetricReporterException e) {
reporterExceptions.add(e);
}
}
}
private void buildScheduledReporter(Properties properties, String reporterClass)
throws MetricReporterException {
try {
Class<?> clazz = Class.forName(reporterClass);
if (CustomCodahaleReporterFactory.class.isAssignableFrom(clazz)) {
CustomCodahaleReporterFactory customCodahaleReporterFactory =
((CustomCodahaleReporterFactory) clazz.getConstructor().newInstance());
com.codahale.metrics.ScheduledReporter scheduledReporter =
customCodahaleReporterFactory.newScheduledReporter(RootMetricContext.get(), properties);
if (scheduledReporter == null) {
LOGGER.warn("Factory {} returns a null scheduledReporter", clazz.getSimpleName());
return;
}
this.codahaleReportersCloser.register(scheduledReporter);
LOGGER.info("Will start reporting metrics using " + reporterClass);
this.codahaleScheduledReporters.add(scheduledReporter);
} else if (CustomReporterFactory.class.isAssignableFrom(clazz)) {
CustomReporterFactory customReporterFactory = ((CustomReporterFactory) clazz.getConstructor().newInstance());
customReporterFactory.newScheduledReporter(properties);
LOGGER.info("Will start reporting metrics using " + reporterClass);
} else {
throw new MetricReporterException("Class " + reporterClass +
" specified by key " + ConfigurationKeys.METRICS_CUSTOM_BUILDERS + " must implement: "
+ CustomCodahaleReporterFactory.class + " or " + CustomReporterFactory.class, ReporterType.CUSTOM, ReporterSinkType.CUSTOM);
}
} catch (ClassNotFoundException exception) {
throw new MetricReporterException(String
.format("Failed to create metric reporter: requested CustomReporterFactory %s not found.", reporterClass),
exception, ReporterType.CUSTOM, ReporterSinkType.CUSTOM);
} catch (NoSuchMethodException exception) {
throw new MetricReporterException(String.format("Failed to create metric reporter: requested CustomReporterFactory %s "
+ "does not have parameterless constructor.", reporterClass), exception, ReporterType.CUSTOM, ReporterSinkType.CUSTOM);
} catch (MetricReporterException exception) {
throw exception;
} catch (Exception exception) {
throw new MetricReporterException("Could not create metric reporter from builder " + reporterClass + ".", exception, ReporterType.CUSTOM, ReporterSinkType.CUSTOM);
}
}
}
|
googleapis/google-cloud-java | 36,255 | java-artifact-registry/proto-google-cloud-artifact-registry-v1beta2/src/main/java/com/google/devtools/artifactregistry/v1beta2/CreateRepositoryRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/devtools/artifactregistry/v1beta2/repository.proto
// Protobuf Java Version: 3.25.8
package com.google.devtools.artifactregistry.v1beta2;
/**
*
*
* <pre>
* The request to create a new repository.
* </pre>
*
* Protobuf type {@code google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest}
*/
public final class CreateRepositoryRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest)
CreateRepositoryRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use CreateRepositoryRequest.newBuilder() to construct.
private CreateRepositoryRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private CreateRepositoryRequest() {
parent_ = "";
repositoryId_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new CreateRepositoryRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.devtools.artifactregistry.v1beta2.RepositoryProto
.internal_static_google_devtools_artifactregistry_v1beta2_CreateRepositoryRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.devtools.artifactregistry.v1beta2.RepositoryProto
.internal_static_google_devtools_artifactregistry_v1beta2_CreateRepositoryRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest.class,
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest.Builder.class);
}
private int bitField0_;
public static final int PARENT_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The name of the parent resource where the repository will be created.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The name of the parent resource where the repository will be created.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int REPOSITORY_ID_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object repositoryId_ = "";
/**
*
*
* <pre>
* The repository id to use for this repository.
* </pre>
*
* <code>string repository_id = 2;</code>
*
* @return The repositoryId.
*/
@java.lang.Override
public java.lang.String getRepositoryId() {
java.lang.Object ref = repositoryId_;
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();
repositoryId_ = s;
return s;
}
}
/**
*
*
* <pre>
* The repository id to use for this repository.
* </pre>
*
* <code>string repository_id = 2;</code>
*
* @return The bytes for repositoryId.
*/
@java.lang.Override
public com.google.protobuf.ByteString getRepositoryIdBytes() {
java.lang.Object ref = repositoryId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
repositoryId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int REPOSITORY_FIELD_NUMBER = 3;
private com.google.devtools.artifactregistry.v1beta2.Repository repository_;
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*
* @return Whether the repository field is set.
*/
@java.lang.Override
public boolean hasRepository() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*
* @return The repository.
*/
@java.lang.Override
public com.google.devtools.artifactregistry.v1beta2.Repository getRepository() {
return repository_ == null
? com.google.devtools.artifactregistry.v1beta2.Repository.getDefaultInstance()
: repository_;
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
@java.lang.Override
public com.google.devtools.artifactregistry.v1beta2.RepositoryOrBuilder getRepositoryOrBuilder() {
return repository_ == null
? com.google.devtools.artifactregistry.v1beta2.Repository.getDefaultInstance()
: repository_;
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(repositoryId_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, repositoryId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
output.writeMessage(3, getRepository());
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(repositoryId_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, repositoryId_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getRepository());
}
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.devtools.artifactregistry.v1beta2.CreateRepositoryRequest)) {
return super.equals(obj);
}
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest other =
(com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest) obj;
if (!getParent().equals(other.getParent())) return false;
if (!getRepositoryId().equals(other.getRepositoryId())) return false;
if (hasRepository() != other.hasRepository()) return false;
if (hasRepository()) {
if (!getRepository().equals(other.getRepository())) 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();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
hash = (37 * hash) + REPOSITORY_ID_FIELD_NUMBER;
hash = (53 * hash) + getRepositoryId().hashCode();
if (hasRepository()) {
hash = (37 * hash) + REPOSITORY_FIELD_NUMBER;
hash = (53 * hash) + getRepository().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest parseFrom(
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest 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.devtools.artifactregistry.v1beta2.CreateRepositoryRequest parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest 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.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
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.devtools.artifactregistry.v1beta2.CreateRepositoryRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest 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.devtools.artifactregistry.v1beta2.CreateRepositoryRequest 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;
}
/**
*
*
* <pre>
* The request to create a new repository.
* </pre>
*
* Protobuf type {@code google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest)
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.devtools.artifactregistry.v1beta2.RepositoryProto
.internal_static_google_devtools_artifactregistry_v1beta2_CreateRepositoryRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.devtools.artifactregistry.v1beta2.RepositoryProto
.internal_static_google_devtools_artifactregistry_v1beta2_CreateRepositoryRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest.class,
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest.Builder.class);
}
// Construct using
// com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getRepositoryFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
parent_ = "";
repositoryId_ = "";
repository_ = null;
if (repositoryBuilder_ != null) {
repositoryBuilder_.dispose();
repositoryBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.devtools.artifactregistry.v1beta2.RepositoryProto
.internal_static_google_devtools_artifactregistry_v1beta2_CreateRepositoryRequest_descriptor;
}
@java.lang.Override
public com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
getDefaultInstanceForType() {
return com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
.getDefaultInstance();
}
@java.lang.Override
public com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest build() {
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest buildPartial() {
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest result =
new com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.parent_ = parent_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.repositoryId_ = repositoryId_;
}
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000004) != 0)) {
result.repository_ = repositoryBuilder_ == null ? repository_ : repositoryBuilder_.build();
to_bitField0_ |= 0x00000001;
}
result.bitField0_ |= to_bitField0_;
}
@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.devtools.artifactregistry.v1beta2.CreateRepositoryRequest) {
return mergeFrom(
(com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest other) {
if (other
== com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
.getDefaultInstance()) return this;
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getRepositoryId().isEmpty()) {
repositoryId_ = other.repositoryId_;
bitField0_ |= 0x00000002;
onChanged();
}
if (other.hasRepository()) {
mergeRepository(other.getRepository());
}
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 10:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
repositoryId_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 26:
{
input.readMessage(getRepositoryFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000004;
break;
} // case 26
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.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The name of the parent resource where the repository will be created.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The name of the parent resource where the repository will be created.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The name of the parent resource where the repository will be created.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The name of the parent resource where the repository will be created.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The name of the parent resource where the repository will be created.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object repositoryId_ = "";
/**
*
*
* <pre>
* The repository id to use for this repository.
* </pre>
*
* <code>string repository_id = 2;</code>
*
* @return The repositoryId.
*/
public java.lang.String getRepositoryId() {
java.lang.Object ref = repositoryId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
repositoryId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The repository id to use for this repository.
* </pre>
*
* <code>string repository_id = 2;</code>
*
* @return The bytes for repositoryId.
*/
public com.google.protobuf.ByteString getRepositoryIdBytes() {
java.lang.Object ref = repositoryId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
repositoryId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The repository id to use for this repository.
* </pre>
*
* <code>string repository_id = 2;</code>
*
* @param value The repositoryId to set.
* @return This builder for chaining.
*/
public Builder setRepositoryId(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
repositoryId_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The repository id to use for this repository.
* </pre>
*
* <code>string repository_id = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearRepositoryId() {
repositoryId_ = getDefaultInstance().getRepositoryId();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* The repository id to use for this repository.
* </pre>
*
* <code>string repository_id = 2;</code>
*
* @param value The bytes for repositoryId to set.
* @return This builder for chaining.
*/
public Builder setRepositoryIdBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
repositoryId_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private com.google.devtools.artifactregistry.v1beta2.Repository repository_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.devtools.artifactregistry.v1beta2.Repository,
com.google.devtools.artifactregistry.v1beta2.Repository.Builder,
com.google.devtools.artifactregistry.v1beta2.RepositoryOrBuilder>
repositoryBuilder_;
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*
* @return Whether the repository field is set.
*/
public boolean hasRepository() {
return ((bitField0_ & 0x00000004) != 0);
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*
* @return The repository.
*/
public com.google.devtools.artifactregistry.v1beta2.Repository getRepository() {
if (repositoryBuilder_ == null) {
return repository_ == null
? com.google.devtools.artifactregistry.v1beta2.Repository.getDefaultInstance()
: repository_;
} else {
return repositoryBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
public Builder setRepository(com.google.devtools.artifactregistry.v1beta2.Repository value) {
if (repositoryBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
repository_ = value;
} else {
repositoryBuilder_.setMessage(value);
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
public Builder setRepository(
com.google.devtools.artifactregistry.v1beta2.Repository.Builder builderForValue) {
if (repositoryBuilder_ == null) {
repository_ = builderForValue.build();
} else {
repositoryBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
public Builder mergeRepository(com.google.devtools.artifactregistry.v1beta2.Repository value) {
if (repositoryBuilder_ == null) {
if (((bitField0_ & 0x00000004) != 0)
&& repository_ != null
&& repository_
!= com.google.devtools.artifactregistry.v1beta2.Repository.getDefaultInstance()) {
getRepositoryBuilder().mergeFrom(value);
} else {
repository_ = value;
}
} else {
repositoryBuilder_.mergeFrom(value);
}
if (repository_ != null) {
bitField0_ |= 0x00000004;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
public Builder clearRepository() {
bitField0_ = (bitField0_ & ~0x00000004);
repository_ = null;
if (repositoryBuilder_ != null) {
repositoryBuilder_.dispose();
repositoryBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
public com.google.devtools.artifactregistry.v1beta2.Repository.Builder getRepositoryBuilder() {
bitField0_ |= 0x00000004;
onChanged();
return getRepositoryFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
public com.google.devtools.artifactregistry.v1beta2.RepositoryOrBuilder
getRepositoryOrBuilder() {
if (repositoryBuilder_ != null) {
return repositoryBuilder_.getMessageOrBuilder();
} else {
return repository_ == null
? com.google.devtools.artifactregistry.v1beta2.Repository.getDefaultInstance()
: repository_;
}
}
/**
*
*
* <pre>
* The repository to be created.
* </pre>
*
* <code>.google.devtools.artifactregistry.v1beta2.Repository repository = 3;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.devtools.artifactregistry.v1beta2.Repository,
com.google.devtools.artifactregistry.v1beta2.Repository.Builder,
com.google.devtools.artifactregistry.v1beta2.RepositoryOrBuilder>
getRepositoryFieldBuilder() {
if (repositoryBuilder_ == null) {
repositoryBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.devtools.artifactregistry.v1beta2.Repository,
com.google.devtools.artifactregistry.v1beta2.Repository.Builder,
com.google.devtools.artifactregistry.v1beta2.RepositoryOrBuilder>(
getRepository(), getParentForChildren(), isClean());
repository_ = null;
}
return repositoryBuilder_;
}
@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.devtools.artifactregistry.v1beta2.CreateRepositoryRequest)
}
// @@protoc_insertion_point(class_scope:google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest)
private static final com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest();
}
public static com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<CreateRepositoryRequest> PARSER =
new com.google.protobuf.AbstractParser<CreateRepositoryRequest>() {
@java.lang.Override
public CreateRepositoryRequest 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<CreateRepositoryRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<CreateRepositoryRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.devtools.artifactregistry.v1beta2.CreateRepositoryRequest
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,275 | java-biglake/proto-google-cloud-biglake-v1/src/main/java/com/google/cloud/biglake/v1/ListIcebergNamespacesRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/biglake/v1/iceberg_rest_catalog.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.biglake.v1;
/**
*
*
* <pre>
* ListIcebergNamespacesRequest
* </pre>
*
* Protobuf type {@code google.cloud.biglake.v1.ListIcebergNamespacesRequest}
*/
public final class ListIcebergNamespacesRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.biglake.v1.ListIcebergNamespacesRequest)
ListIcebergNamespacesRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListIcebergNamespacesRequest.newBuilder() to construct.
private ListIcebergNamespacesRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListIcebergNamespacesRequest() {
pageToken_ = "";
apiParent_ = "";
parent_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListIcebergNamespacesRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.biglake.v1.IcebergRestCatalogProto
.internal_static_google_cloud_biglake_v1_ListIcebergNamespacesRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.biglake.v1.IcebergRestCatalogProto
.internal_static_google_cloud_biglake_v1_ListIcebergNamespacesRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.biglake.v1.ListIcebergNamespacesRequest.class,
com.google.cloud.biglake.v1.ListIcebergNamespacesRequest.Builder.class);
}
public static final int PAGE_TOKEN_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* Optional. PageToken
* </pre>
*
* <code>string page_token = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageToken.
*/
@java.lang.Override
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
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();
pageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* Optional. PageToken
* </pre>
*
* <code>string page_token = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for pageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PAGE_SIZE_FIELD_NUMBER = 2;
private int pageSize_ = 0;
/**
*
*
* <pre>
* Optional. For servers that support pagination, this signals an upper bound
* of the number of results that a client will receive. For servers that do
* not support pagination, clients may receive results larger than the
* indicated `pageSize`.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
public static final int API_PARENT_FIELD_NUMBER = 3;
@SuppressWarnings("serial")
private volatile java.lang.Object apiParent_ = "";
/**
*
*
* <pre>
* Required. The parent from the resource path.
* </pre>
*
* <code>string api_parent = 3 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The apiParent.
*/
@java.lang.Override
public java.lang.String getApiParent() {
java.lang.Object ref = apiParent_;
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();
apiParent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The parent from the resource path.
* </pre>
*
* <code>string api_parent = 3 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for apiParent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getApiParentBytes() {
java.lang.Object ref = apiParent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
apiParent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PARENT_FIELD_NUMBER = 4;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Optional. An optional namespace, underneath which to list namespaces. If
* not provided or empty, all top-level namespaces should be listed. If parent
* is a multipart namespace, the parts must be separated by the unit separator
* (`0x1F`) byte.
* Not a real parent, so ST_NOT_REQUIRED.
* </pre>
*
* <code>string parent = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Optional. An optional namespace, underneath which to list namespaces. If
* not provided or empty, all top-level namespaces should be listed. If parent
* is a multipart namespace, the parts must be separated by the unit separator
* (`0x1F`) byte.
* Not a real parent, so ST_NOT_REQUIRED.
* </pre>
*
* <code>string parent = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, pageToken_);
}
if (pageSize_ != 0) {
output.writeInt32(2, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(apiParent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, apiParent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, parent_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, pageToken_);
}
if (pageSize_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(apiParent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, apiParent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, parent_);
}
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.biglake.v1.ListIcebergNamespacesRequest)) {
return super.equals(obj);
}
com.google.cloud.biglake.v1.ListIcebergNamespacesRequest other =
(com.google.cloud.biglake.v1.ListIcebergNamespacesRequest) obj;
if (!getPageToken().equals(other.getPageToken())) return false;
if (getPageSize() != other.getPageSize()) return false;
if (!getApiParent().equals(other.getApiParent())) return false;
if (!getParent().equals(other.getParent())) 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();
hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getPageToken().hashCode();
hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER;
hash = (53 * hash) + getPageSize();
hash = (37 * hash) + API_PARENT_FIELD_NUMBER;
hash = (53 * hash) + getApiParent().hashCode();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest 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.biglake.v1.ListIcebergNamespacesRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest 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.biglake.v1.ListIcebergNamespacesRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest 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.biglake.v1.ListIcebergNamespacesRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest 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.biglake.v1.ListIcebergNamespacesRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest 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.biglake.v1.ListIcebergNamespacesRequest 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;
}
/**
*
*
* <pre>
* ListIcebergNamespacesRequest
* </pre>
*
* Protobuf type {@code google.cloud.biglake.v1.ListIcebergNamespacesRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.biglake.v1.ListIcebergNamespacesRequest)
com.google.cloud.biglake.v1.ListIcebergNamespacesRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.biglake.v1.IcebergRestCatalogProto
.internal_static_google_cloud_biglake_v1_ListIcebergNamespacesRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.biglake.v1.IcebergRestCatalogProto
.internal_static_google_cloud_biglake_v1_ListIcebergNamespacesRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.biglake.v1.ListIcebergNamespacesRequest.class,
com.google.cloud.biglake.v1.ListIcebergNamespacesRequest.Builder.class);
}
// Construct using com.google.cloud.biglake.v1.ListIcebergNamespacesRequest.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
pageToken_ = "";
pageSize_ = 0;
apiParent_ = "";
parent_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.biglake.v1.IcebergRestCatalogProto
.internal_static_google_cloud_biglake_v1_ListIcebergNamespacesRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.biglake.v1.ListIcebergNamespacesRequest getDefaultInstanceForType() {
return com.google.cloud.biglake.v1.ListIcebergNamespacesRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.biglake.v1.ListIcebergNamespacesRequest build() {
com.google.cloud.biglake.v1.ListIcebergNamespacesRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.biglake.v1.ListIcebergNamespacesRequest buildPartial() {
com.google.cloud.biglake.v1.ListIcebergNamespacesRequest result =
new com.google.cloud.biglake.v1.ListIcebergNamespacesRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.biglake.v1.ListIcebergNamespacesRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.pageToken_ = pageToken_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.pageSize_ = pageSize_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.apiParent_ = apiParent_;
}
if (((from_bitField0_ & 0x00000008) != 0)) {
result.parent_ = parent_;
}
}
@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.biglake.v1.ListIcebergNamespacesRequest) {
return mergeFrom((com.google.cloud.biglake.v1.ListIcebergNamespacesRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.biglake.v1.ListIcebergNamespacesRequest other) {
if (other == com.google.cloud.biglake.v1.ListIcebergNamespacesRequest.getDefaultInstance())
return this;
if (!other.getPageToken().isEmpty()) {
pageToken_ = other.pageToken_;
bitField0_ |= 0x00000001;
onChanged();
}
if (other.getPageSize() != 0) {
setPageSize(other.getPageSize());
}
if (!other.getApiParent().isEmpty()) {
apiParent_ = other.apiParent_;
bitField0_ |= 0x00000004;
onChanged();
}
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000008;
onChanged();
}
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 10:
{
pageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 16:
{
pageSize_ = input.readInt32();
bitField0_ |= 0x00000002;
break;
} // case 16
case 26:
{
apiParent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000004;
break;
} // case 26
case 34:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000008;
break;
} // case 34
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.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* Optional. PageToken
* </pre>
*
* <code>string page_token = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageToken.
*/
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
pageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Optional. PageToken
* </pre>
*
* <code>string page_token = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for pageToken.
*/
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Optional. PageToken
* </pre>
*
* <code>string page_token = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
pageToken_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. PageToken
* </pre>
*
* <code>string page_token = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearPageToken() {
pageToken_ = getDefaultInstance().getPageToken();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. PageToken
* </pre>
*
* <code>string page_token = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
pageToken_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private int pageSize_;
/**
*
*
* <pre>
* Optional. For servers that support pagination, this signals an upper bound
* of the number of results that a client will receive. For servers that do
* not support pagination, clients may receive results larger than the
* indicated `pageSize`.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
/**
*
*
* <pre>
* Optional. For servers that support pagination, this signals an upper bound
* of the number of results that a client will receive. For servers that do
* not support pagination, clients may receive results larger than the
* indicated `pageSize`.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The pageSize to set.
* @return This builder for chaining.
*/
public Builder setPageSize(int value) {
pageSize_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. For servers that support pagination, this signals an upper bound
* of the number of results that a client will receive. For servers that do
* not support pagination, clients may receive results larger than the
* indicated `pageSize`.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearPageSize() {
bitField0_ = (bitField0_ & ~0x00000002);
pageSize_ = 0;
onChanged();
return this;
}
private java.lang.Object apiParent_ = "";
/**
*
*
* <pre>
* Required. The parent from the resource path.
* </pre>
*
* <code>string api_parent = 3 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The apiParent.
*/
public java.lang.String getApiParent() {
java.lang.Object ref = apiParent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
apiParent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The parent from the resource path.
* </pre>
*
* <code>string api_parent = 3 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for apiParent.
*/
public com.google.protobuf.ByteString getApiParentBytes() {
java.lang.Object ref = apiParent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
apiParent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The parent from the resource path.
* </pre>
*
* <code>string api_parent = 3 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The apiParent to set.
* @return This builder for chaining.
*/
public Builder setApiParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
apiParent_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The parent from the resource path.
* </pre>
*
* <code>string api_parent = 3 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return This builder for chaining.
*/
public Builder clearApiParent() {
apiParent_ = getDefaultInstance().getApiParent();
bitField0_ = (bitField0_ & ~0x00000004);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The parent from the resource path.
* </pre>
*
* <code>string api_parent = 3 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The bytes for apiParent to set.
* @return This builder for chaining.
*/
public Builder setApiParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
apiParent_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
private java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Optional. An optional namespace, underneath which to list namespaces. If
* not provided or empty, all top-level namespaces should be listed. If parent
* is a multipart namespace, the parts must be separated by the unit separator
* (`0x1F`) byte.
* Not a real parent, so ST_NOT_REQUIRED.
* </pre>
*
* <code>string parent = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Optional. An optional namespace, underneath which to list namespaces. If
* not provided or empty, all top-level namespaces should be listed. If parent
* is a multipart namespace, the parts must be separated by the unit separator
* (`0x1F`) byte.
* Not a real parent, so ST_NOT_REQUIRED.
* </pre>
*
* <code>string parent = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Optional. An optional namespace, underneath which to list namespaces. If
* not provided or empty, all top-level namespaces should be listed. If parent
* is a multipart namespace, the parts must be separated by the unit separator
* (`0x1F`) byte.
* Not a real parent, so ST_NOT_REQUIRED.
* </pre>
*
* <code>string parent = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. An optional namespace, underneath which to list namespaces. If
* not provided or empty, all top-level namespaces should be listed. If parent
* is a multipart namespace, the parts must be separated by the unit separator
* (`0x1F`) byte.
* Not a real parent, so ST_NOT_REQUIRED.
* </pre>
*
* <code>string parent = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000008);
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. An optional namespace, underneath which to list namespaces. If
* not provided or empty, all top-level namespaces should be listed. If parent
* is a multipart namespace, the parts must be separated by the unit separator
* (`0x1F`) byte.
* Not a real parent, so ST_NOT_REQUIRED.
* </pre>
*
* <code>string parent = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
@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.biglake.v1.ListIcebergNamespacesRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.biglake.v1.ListIcebergNamespacesRequest)
private static final com.google.cloud.biglake.v1.ListIcebergNamespacesRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.biglake.v1.ListIcebergNamespacesRequest();
}
public static com.google.cloud.biglake.v1.ListIcebergNamespacesRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListIcebergNamespacesRequest> PARSER =
new com.google.protobuf.AbstractParser<ListIcebergNamespacesRequest>() {
@java.lang.Override
public ListIcebergNamespacesRequest 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<ListIcebergNamespacesRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListIcebergNamespacesRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.biglake.v1.ListIcebergNamespacesRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,268 | java-alloydb/proto-google-cloud-alloydb-v1alpha/src/main/java/com/google/cloud/alloydb/v1alpha/ListDatabasesRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/alloydb/v1alpha/service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.alloydb.v1alpha;
/**
*
*
* <pre>
* Message for ListDatabases request.
* </pre>
*
* Protobuf type {@code google.cloud.alloydb.v1alpha.ListDatabasesRequest}
*/
public final class ListDatabasesRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.alloydb.v1alpha.ListDatabasesRequest)
ListDatabasesRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListDatabasesRequest.newBuilder() to construct.
private ListDatabasesRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListDatabasesRequest() {
parent_ = "";
pageToken_ = "";
filter_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListDatabasesRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.alloydb.v1alpha.ServiceProto
.internal_static_google_cloud_alloydb_v1alpha_ListDatabasesRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.alloydb.v1alpha.ServiceProto
.internal_static_google_cloud_alloydb_v1alpha_ListDatabasesRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.alloydb.v1alpha.ListDatabasesRequest.class,
com.google.cloud.alloydb.v1alpha.ListDatabasesRequest.Builder.class);
}
public static final int PARENT_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. Parent value for ListDatabasesRequest.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. Parent value for ListDatabasesRequest.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PAGE_SIZE_FIELD_NUMBER = 2;
private int pageSize_ = 0;
/**
*
*
* <pre>
* Optional. The maximum number of databases to return. The service may return
* fewer than this value. If unspecified, 2000 is the default page_size. The
* max value of page_size will be 4000, values above max will be coerced to
* max.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
public static final int PAGE_TOKEN_FIELD_NUMBER = 3;
@SuppressWarnings("serial")
private volatile java.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* Optional. A page token, received from a previous `ListDatabases` call.
* This should be provided to retrieve the subsequent page.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageToken.
*/
@java.lang.Override
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
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();
pageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* Optional. A page token, received from a previous `ListDatabases` call.
* This should be provided to retrieve the subsequent page.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for pageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int FILTER_FIELD_NUMBER = 4;
@SuppressWarnings("serial")
private volatile java.lang.Object filter_ = "";
/**
*
*
* <pre>
* Optional. Filtering results.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The filter.
*/
@java.lang.Override
public java.lang.String getFilter() {
java.lang.Object ref = filter_;
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();
filter_ = s;
return s;
}
}
/**
*
*
* <pre>
* Optional. Filtering results.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for filter.
*/
@java.lang.Override
public com.google.protobuf.ByteString getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_);
}
if (pageSize_ != 0) {
output.writeInt32(2, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, pageToken_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, filter_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_);
}
if (pageSize_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, pageToken_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, filter_);
}
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.alloydb.v1alpha.ListDatabasesRequest)) {
return super.equals(obj);
}
com.google.cloud.alloydb.v1alpha.ListDatabasesRequest other =
(com.google.cloud.alloydb.v1alpha.ListDatabasesRequest) obj;
if (!getParent().equals(other.getParent())) return false;
if (getPageSize() != other.getPageSize()) return false;
if (!getPageToken().equals(other.getPageToken())) return false;
if (!getFilter().equals(other.getFilter())) 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();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER;
hash = (53 * hash) + getPageSize();
hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getPageToken().hashCode();
hash = (37 * hash) + FILTER_FIELD_NUMBER;
hash = (53 * hash) + getFilter().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest 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.alloydb.v1alpha.ListDatabasesRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest 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.alloydb.v1alpha.ListDatabasesRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest 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.alloydb.v1alpha.ListDatabasesRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest 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.alloydb.v1alpha.ListDatabasesRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest 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.alloydb.v1alpha.ListDatabasesRequest 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;
}
/**
*
*
* <pre>
* Message for ListDatabases request.
* </pre>
*
* Protobuf type {@code google.cloud.alloydb.v1alpha.ListDatabasesRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.alloydb.v1alpha.ListDatabasesRequest)
com.google.cloud.alloydb.v1alpha.ListDatabasesRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.alloydb.v1alpha.ServiceProto
.internal_static_google_cloud_alloydb_v1alpha_ListDatabasesRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.alloydb.v1alpha.ServiceProto
.internal_static_google_cloud_alloydb_v1alpha_ListDatabasesRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.alloydb.v1alpha.ListDatabasesRequest.class,
com.google.cloud.alloydb.v1alpha.ListDatabasesRequest.Builder.class);
}
// Construct using com.google.cloud.alloydb.v1alpha.ListDatabasesRequest.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
parent_ = "";
pageSize_ = 0;
pageToken_ = "";
filter_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.alloydb.v1alpha.ServiceProto
.internal_static_google_cloud_alloydb_v1alpha_ListDatabasesRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.alloydb.v1alpha.ListDatabasesRequest getDefaultInstanceForType() {
return com.google.cloud.alloydb.v1alpha.ListDatabasesRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.alloydb.v1alpha.ListDatabasesRequest build() {
com.google.cloud.alloydb.v1alpha.ListDatabasesRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.alloydb.v1alpha.ListDatabasesRequest buildPartial() {
com.google.cloud.alloydb.v1alpha.ListDatabasesRequest result =
new com.google.cloud.alloydb.v1alpha.ListDatabasesRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.alloydb.v1alpha.ListDatabasesRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.parent_ = parent_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.pageSize_ = pageSize_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.pageToken_ = pageToken_;
}
if (((from_bitField0_ & 0x00000008) != 0)) {
result.filter_ = filter_;
}
}
@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.alloydb.v1alpha.ListDatabasesRequest) {
return mergeFrom((com.google.cloud.alloydb.v1alpha.ListDatabasesRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.alloydb.v1alpha.ListDatabasesRequest other) {
if (other == com.google.cloud.alloydb.v1alpha.ListDatabasesRequest.getDefaultInstance())
return this;
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000001;
onChanged();
}
if (other.getPageSize() != 0) {
setPageSize(other.getPageSize());
}
if (!other.getPageToken().isEmpty()) {
pageToken_ = other.pageToken_;
bitField0_ |= 0x00000004;
onChanged();
}
if (!other.getFilter().isEmpty()) {
filter_ = other.filter_;
bitField0_ |= 0x00000008;
onChanged();
}
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 10:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 16:
{
pageSize_ = input.readInt32();
bitField0_ |= 0x00000002;
break;
} // case 16
case 26:
{
pageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000004;
break;
} // case 26
case 34:
{
filter_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000008;
break;
} // case 34
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.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. Parent value for ListDatabasesRequest.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. Parent value for ListDatabasesRequest.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. Parent value for ListDatabasesRequest.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Parent value for ListDatabasesRequest.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Parent value for ListDatabasesRequest.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private int pageSize_;
/**
*
*
* <pre>
* Optional. The maximum number of databases to return. The service may return
* fewer than this value. If unspecified, 2000 is the default page_size. The
* max value of page_size will be 4000, values above max will be coerced to
* max.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
/**
*
*
* <pre>
* Optional. The maximum number of databases to return. The service may return
* fewer than this value. If unspecified, 2000 is the default page_size. The
* max value of page_size will be 4000, values above max will be coerced to
* max.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The pageSize to set.
* @return This builder for chaining.
*/
public Builder setPageSize(int value) {
pageSize_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. The maximum number of databases to return. The service may return
* fewer than this value. If unspecified, 2000 is the default page_size. The
* max value of page_size will be 4000, values above max will be coerced to
* max.
* </pre>
*
* <code>int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearPageSize() {
bitField0_ = (bitField0_ & ~0x00000002);
pageSize_ = 0;
onChanged();
return this;
}
private java.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* Optional. A page token, received from a previous `ListDatabases` call.
* This should be provided to retrieve the subsequent page.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The pageToken.
*/
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
pageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Optional. A page token, received from a previous `ListDatabases` call.
* This should be provided to retrieve the subsequent page.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for pageToken.
*/
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Optional. A page token, received from a previous `ListDatabases` call.
* This should be provided to retrieve the subsequent page.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
pageToken_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. A page token, received from a previous `ListDatabases` call.
* This should be provided to retrieve the subsequent page.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearPageToken() {
pageToken_ = getDefaultInstance().getPageToken();
bitField0_ = (bitField0_ & ~0x00000004);
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. A page token, received from a previous `ListDatabases` call.
* This should be provided to retrieve the subsequent page.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
pageToken_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
private java.lang.Object filter_ = "";
/**
*
*
* <pre>
* Optional. Filtering results.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The filter.
*/
public java.lang.String getFilter() {
java.lang.Object ref = filter_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
filter_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Optional. Filtering results.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for filter.
*/
public com.google.protobuf.ByteString getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Optional. Filtering results.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The filter to set.
* @return This builder for chaining.
*/
public Builder setFilter(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
filter_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Filtering results.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearFilter() {
filter_ = getDefaultInstance().getFilter();
bitField0_ = (bitField0_ & ~0x00000008);
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Filtering results.
* This field is currently not supported, its value will be ignored if passed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for filter to set.
* @return This builder for chaining.
*/
public Builder setFilterBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
filter_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
@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.alloydb.v1alpha.ListDatabasesRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.alloydb.v1alpha.ListDatabasesRequest)
private static final com.google.cloud.alloydb.v1alpha.ListDatabasesRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.alloydb.v1alpha.ListDatabasesRequest();
}
public static com.google.cloud.alloydb.v1alpha.ListDatabasesRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListDatabasesRequest> PARSER =
new com.google.protobuf.AbstractParser<ListDatabasesRequest>() {
@java.lang.Override
public ListDatabasesRequest 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<ListDatabasesRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListDatabasesRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.alloydb.v1alpha.ListDatabasesRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,288 | java-oracledatabase/proto-google-cloud-oracledatabase-v1/src/main/java/com/google/cloud/oracledatabase/v1/DbServer.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/oracledatabase/v1/db_server.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.oracledatabase.v1;
/**
*
*
* <pre>
* Details of the database server resource.
* https://docs.oracle.com/en-us/iaas/api/#/en/database/20160918/DbServer/
* </pre>
*
* Protobuf type {@code google.cloud.oracledatabase.v1.DbServer}
*/
public final class DbServer extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.oracledatabase.v1.DbServer)
DbServerOrBuilder {
private static final long serialVersionUID = 0L;
// Use DbServer.newBuilder() to construct.
private DbServer(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private DbServer() {
name_ = "";
displayName_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new DbServer();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.oracledatabase.v1.DbServerProto
.internal_static_google_cloud_oracledatabase_v1_DbServer_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.oracledatabase.v1.DbServerProto
.internal_static_google_cloud_oracledatabase_v1_DbServer_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.oracledatabase.v1.DbServer.class,
com.google.cloud.oracledatabase.v1.DbServer.Builder.class);
}
private int bitField0_;
public static final int NAME_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object name_ = "";
/**
*
*
* <pre>
* Identifier. The name of the database server resource with the format:
* projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}
* </pre>
*
* <code>string name = 1 [(.google.api.field_behavior) = IDENTIFIER];</code>
*
* @return The name.
*/
@java.lang.Override
public java.lang.String getName() {
java.lang.Object ref = name_;
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();
name_ = s;
return s;
}
}
/**
*
*
* <pre>
* Identifier. The name of the database server resource with the format:
* projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}
* </pre>
*
* <code>string name = 1 [(.google.api.field_behavior) = IDENTIFIER];</code>
*
* @return The bytes for name.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int DISPLAY_NAME_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object displayName_ = "";
/**
*
*
* <pre>
* Optional. User friendly name for this resource.
* </pre>
*
* <code>string display_name = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The displayName.
*/
@java.lang.Override
public java.lang.String getDisplayName() {
java.lang.Object ref = displayName_;
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();
displayName_ = s;
return s;
}
}
/**
*
*
* <pre>
* Optional. User friendly name for this resource.
* </pre>
*
* <code>string display_name = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for displayName.
*/
@java.lang.Override
public com.google.protobuf.ByteString getDisplayNameBytes() {
java.lang.Object ref = displayName_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
displayName_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PROPERTIES_FIELD_NUMBER = 3;
private com.google.cloud.oracledatabase.v1.DbServerProperties properties_;
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return Whether the properties field is set.
*/
@java.lang.Override
public boolean hasProperties() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return The properties.
*/
@java.lang.Override
public com.google.cloud.oracledatabase.v1.DbServerProperties getProperties() {
return properties_ == null
? com.google.cloud.oracledatabase.v1.DbServerProperties.getDefaultInstance()
: properties_;
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
@java.lang.Override
public com.google.cloud.oracledatabase.v1.DbServerPropertiesOrBuilder getPropertiesOrBuilder() {
return properties_ == null
? com.google.cloud.oracledatabase.v1.DbServerProperties.getDefaultInstance()
: properties_;
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(displayName_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, displayName_);
}
if (((bitField0_ & 0x00000001) != 0)) {
output.writeMessage(3, getProperties());
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(displayName_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, displayName_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getProperties());
}
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.oracledatabase.v1.DbServer)) {
return super.equals(obj);
}
com.google.cloud.oracledatabase.v1.DbServer other =
(com.google.cloud.oracledatabase.v1.DbServer) obj;
if (!getName().equals(other.getName())) return false;
if (!getDisplayName().equals(other.getDisplayName())) return false;
if (hasProperties() != other.hasProperties()) return false;
if (hasProperties()) {
if (!getProperties().equals(other.getProperties())) 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();
hash = (37 * hash) + NAME_FIELD_NUMBER;
hash = (53 * hash) + getName().hashCode();
hash = (37 * hash) + DISPLAY_NAME_FIELD_NUMBER;
hash = (53 * hash) + getDisplayName().hashCode();
if (hasProperties()) {
hash = (37 * hash) + PROPERTIES_FIELD_NUMBER;
hash = (53 * hash) + getProperties().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.oracledatabase.v1.DbServer parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.oracledatabase.v1.DbServer 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.oracledatabase.v1.DbServer parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.oracledatabase.v1.DbServer 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.oracledatabase.v1.DbServer parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.oracledatabase.v1.DbServer parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.oracledatabase.v1.DbServer parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.oracledatabase.v1.DbServer 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.oracledatabase.v1.DbServer parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.oracledatabase.v1.DbServer 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.oracledatabase.v1.DbServer parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.oracledatabase.v1.DbServer 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.oracledatabase.v1.DbServer 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;
}
/**
*
*
* <pre>
* Details of the database server resource.
* https://docs.oracle.com/en-us/iaas/api/#/en/database/20160918/DbServer/
* </pre>
*
* Protobuf type {@code google.cloud.oracledatabase.v1.DbServer}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.oracledatabase.v1.DbServer)
com.google.cloud.oracledatabase.v1.DbServerOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.oracledatabase.v1.DbServerProto
.internal_static_google_cloud_oracledatabase_v1_DbServer_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.oracledatabase.v1.DbServerProto
.internal_static_google_cloud_oracledatabase_v1_DbServer_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.oracledatabase.v1.DbServer.class,
com.google.cloud.oracledatabase.v1.DbServer.Builder.class);
}
// Construct using com.google.cloud.oracledatabase.v1.DbServer.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getPropertiesFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
name_ = "";
displayName_ = "";
properties_ = null;
if (propertiesBuilder_ != null) {
propertiesBuilder_.dispose();
propertiesBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.oracledatabase.v1.DbServerProto
.internal_static_google_cloud_oracledatabase_v1_DbServer_descriptor;
}
@java.lang.Override
public com.google.cloud.oracledatabase.v1.DbServer getDefaultInstanceForType() {
return com.google.cloud.oracledatabase.v1.DbServer.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.oracledatabase.v1.DbServer build() {
com.google.cloud.oracledatabase.v1.DbServer result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.oracledatabase.v1.DbServer buildPartial() {
com.google.cloud.oracledatabase.v1.DbServer result =
new com.google.cloud.oracledatabase.v1.DbServer(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.oracledatabase.v1.DbServer result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.name_ = name_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.displayName_ = displayName_;
}
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000004) != 0)) {
result.properties_ = propertiesBuilder_ == null ? properties_ : propertiesBuilder_.build();
to_bitField0_ |= 0x00000001;
}
result.bitField0_ |= to_bitField0_;
}
@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.oracledatabase.v1.DbServer) {
return mergeFrom((com.google.cloud.oracledatabase.v1.DbServer) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.oracledatabase.v1.DbServer other) {
if (other == com.google.cloud.oracledatabase.v1.DbServer.getDefaultInstance()) return this;
if (!other.getName().isEmpty()) {
name_ = other.name_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getDisplayName().isEmpty()) {
displayName_ = other.displayName_;
bitField0_ |= 0x00000002;
onChanged();
}
if (other.hasProperties()) {
mergeProperties(other.getProperties());
}
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 10:
{
name_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
displayName_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 26:
{
input.readMessage(getPropertiesFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000004;
break;
} // case 26
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.lang.Object name_ = "";
/**
*
*
* <pre>
* Identifier. The name of the database server resource with the format:
* projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}
* </pre>
*
* <code>string name = 1 [(.google.api.field_behavior) = IDENTIFIER];</code>
*
* @return The name.
*/
public java.lang.String getName() {
java.lang.Object ref = name_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
name_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Identifier. The name of the database server resource with the format:
* projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}
* </pre>
*
* <code>string name = 1 [(.google.api.field_behavior) = IDENTIFIER];</code>
*
* @return The bytes for name.
*/
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Identifier. The name of the database server resource with the format:
* projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}
* </pre>
*
* <code>string name = 1 [(.google.api.field_behavior) = IDENTIFIER];</code>
*
* @param value The name to set.
* @return This builder for chaining.
*/
public Builder setName(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
name_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Identifier. The name of the database server resource with the format:
* projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}
* </pre>
*
* <code>string name = 1 [(.google.api.field_behavior) = IDENTIFIER];</code>
*
* @return This builder for chaining.
*/
public Builder clearName() {
name_ = getDefaultInstance().getName();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Identifier. The name of the database server resource with the format:
* projects/{project}/locations/{location}/cloudExadataInfrastructures/{cloud_exadata_infrastructure}/dbServers/{db_server}
* </pre>
*
* <code>string name = 1 [(.google.api.field_behavior) = IDENTIFIER];</code>
*
* @param value The bytes for name to set.
* @return This builder for chaining.
*/
public Builder setNameBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
name_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object displayName_ = "";
/**
*
*
* <pre>
* Optional. User friendly name for this resource.
* </pre>
*
* <code>string display_name = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The displayName.
*/
public java.lang.String getDisplayName() {
java.lang.Object ref = displayName_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
displayName_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Optional. User friendly name for this resource.
* </pre>
*
* <code>string display_name = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for displayName.
*/
public com.google.protobuf.ByteString getDisplayNameBytes() {
java.lang.Object ref = displayName_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
displayName_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Optional. User friendly name for this resource.
* </pre>
*
* <code>string display_name = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The displayName to set.
* @return This builder for chaining.
*/
public Builder setDisplayName(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
displayName_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. User friendly name for this resource.
* </pre>
*
* <code>string display_name = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearDisplayName() {
displayName_ = getDefaultInstance().getDisplayName();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. User friendly name for this resource.
* </pre>
*
* <code>string display_name = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for displayName to set.
* @return This builder for chaining.
*/
public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
displayName_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private com.google.cloud.oracledatabase.v1.DbServerProperties properties_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.oracledatabase.v1.DbServerProperties,
com.google.cloud.oracledatabase.v1.DbServerProperties.Builder,
com.google.cloud.oracledatabase.v1.DbServerPropertiesOrBuilder>
propertiesBuilder_;
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return Whether the properties field is set.
*/
public boolean hasProperties() {
return ((bitField0_ & 0x00000004) != 0);
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*
* @return The properties.
*/
public com.google.cloud.oracledatabase.v1.DbServerProperties getProperties() {
if (propertiesBuilder_ == null) {
return properties_ == null
? com.google.cloud.oracledatabase.v1.DbServerProperties.getDefaultInstance()
: properties_;
} else {
return propertiesBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder setProperties(com.google.cloud.oracledatabase.v1.DbServerProperties value) {
if (propertiesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
properties_ = value;
} else {
propertiesBuilder_.setMessage(value);
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder setProperties(
com.google.cloud.oracledatabase.v1.DbServerProperties.Builder builderForValue) {
if (propertiesBuilder_ == null) {
properties_ = builderForValue.build();
} else {
propertiesBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder mergeProperties(com.google.cloud.oracledatabase.v1.DbServerProperties value) {
if (propertiesBuilder_ == null) {
if (((bitField0_ & 0x00000004) != 0)
&& properties_ != null
&& properties_
!= com.google.cloud.oracledatabase.v1.DbServerProperties.getDefaultInstance()) {
getPropertiesBuilder().mergeFrom(value);
} else {
properties_ = value;
}
} else {
propertiesBuilder_.mergeFrom(value);
}
if (properties_ != null) {
bitField0_ |= 0x00000004;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public Builder clearProperties() {
bitField0_ = (bitField0_ & ~0x00000004);
properties_ = null;
if (propertiesBuilder_ != null) {
propertiesBuilder_.dispose();
propertiesBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public com.google.cloud.oracledatabase.v1.DbServerProperties.Builder getPropertiesBuilder() {
bitField0_ |= 0x00000004;
onChanged();
return getPropertiesFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
public com.google.cloud.oracledatabase.v1.DbServerPropertiesOrBuilder getPropertiesOrBuilder() {
if (propertiesBuilder_ != null) {
return propertiesBuilder_.getMessageOrBuilder();
} else {
return properties_ == null
? com.google.cloud.oracledatabase.v1.DbServerProperties.getDefaultInstance()
: properties_;
}
}
/**
*
*
* <pre>
* Optional. Various properties of the database server.
* </pre>
*
* <code>
* .google.cloud.oracledatabase.v1.DbServerProperties properties = 3 [(.google.api.field_behavior) = OPTIONAL];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.oracledatabase.v1.DbServerProperties,
com.google.cloud.oracledatabase.v1.DbServerProperties.Builder,
com.google.cloud.oracledatabase.v1.DbServerPropertiesOrBuilder>
getPropertiesFieldBuilder() {
if (propertiesBuilder_ == null) {
propertiesBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.oracledatabase.v1.DbServerProperties,
com.google.cloud.oracledatabase.v1.DbServerProperties.Builder,
com.google.cloud.oracledatabase.v1.DbServerPropertiesOrBuilder>(
getProperties(), getParentForChildren(), isClean());
properties_ = null;
}
return propertiesBuilder_;
}
@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.oracledatabase.v1.DbServer)
}
// @@protoc_insertion_point(class_scope:google.cloud.oracledatabase.v1.DbServer)
private static final com.google.cloud.oracledatabase.v1.DbServer DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.oracledatabase.v1.DbServer();
}
public static com.google.cloud.oracledatabase.v1.DbServer getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<DbServer> PARSER =
new com.google.protobuf.AbstractParser<DbServer>() {
@java.lang.Override
public DbServer 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<DbServer> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<DbServer> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.oracledatabase.v1.DbServer getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,305 | java-dataplex/proto-google-cloud-dataplex-v1/src/main/java/com/google/cloud/dataplex/v1/UpdateDataAttributeRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/dataplex/v1/data_taxonomy.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.dataplex.v1;
/**
*
*
* <pre>
* Update DataAttribute request.
* </pre>
*
* Protobuf type {@code google.cloud.dataplex.v1.UpdateDataAttributeRequest}
*/
public final class UpdateDataAttributeRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.dataplex.v1.UpdateDataAttributeRequest)
UpdateDataAttributeRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateDataAttributeRequest.newBuilder() to construct.
private UpdateDataAttributeRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateDataAttributeRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateDataAttributeRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.dataplex.v1.DataTaxonomyProto
.internal_static_google_cloud_dataplex_v1_UpdateDataAttributeRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.dataplex.v1.DataTaxonomyProto
.internal_static_google_cloud_dataplex_v1_UpdateDataAttributeRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.dataplex.v1.UpdateDataAttributeRequest.class,
com.google.cloud.dataplex.v1.UpdateDataAttributeRequest.Builder.class);
}
private int bitField0_;
public static final int UPDATE_MASK_FIELD_NUMBER = 1;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
public static final int DATA_ATTRIBUTE_FIELD_NUMBER = 2;
private com.google.cloud.dataplex.v1.DataAttribute dataAttribute_;
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the dataAttribute field is set.
*/
@java.lang.Override
public boolean hasDataAttribute() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The dataAttribute.
*/
@java.lang.Override
public com.google.cloud.dataplex.v1.DataAttribute getDataAttribute() {
return dataAttribute_ == null
? com.google.cloud.dataplex.v1.DataAttribute.getDefaultInstance()
: dataAttribute_;
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.dataplex.v1.DataAttributeOrBuilder getDataAttributeOrBuilder() {
return dataAttribute_ == null
? com.google.cloud.dataplex.v1.DataAttribute.getDefaultInstance()
: dataAttribute_;
}
public static final int VALIDATE_ONLY_FIELD_NUMBER = 3;
private boolean validateOnly_ = false;
/**
*
*
* <pre>
* Optional. Only validate the request, but do not perform mutations.
* The default is false.
* </pre>
*
* <code>bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The validateOnly.
*/
@java.lang.Override
public boolean getValidateOnly() {
return validateOnly_;
}
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)) {
output.writeMessage(1, getUpdateMask());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getDataAttribute());
}
if (validateOnly_ != false) {
output.writeBool(3, validateOnly_);
}
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.CodedOutputStream.computeMessageSize(1, getUpdateMask());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getDataAttribute());
}
if (validateOnly_ != false) {
size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, validateOnly_);
}
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.dataplex.v1.UpdateDataAttributeRequest)) {
return super.equals(obj);
}
com.google.cloud.dataplex.v1.UpdateDataAttributeRequest other =
(com.google.cloud.dataplex.v1.UpdateDataAttributeRequest) obj;
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) return false;
}
if (hasDataAttribute() != other.hasDataAttribute()) return false;
if (hasDataAttribute()) {
if (!getDataAttribute().equals(other.getDataAttribute())) return false;
}
if (getValidateOnly() != other.getValidateOnly()) 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 (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
if (hasDataAttribute()) {
hash = (37 * hash) + DATA_ATTRIBUTE_FIELD_NUMBER;
hash = (53 * hash) + getDataAttribute().hashCode();
}
hash = (37 * hash) + VALIDATE_ONLY_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getValidateOnly());
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest 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.dataplex.v1.UpdateDataAttributeRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest 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.dataplex.v1.UpdateDataAttributeRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest 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.dataplex.v1.UpdateDataAttributeRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest 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.dataplex.v1.UpdateDataAttributeRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest 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.dataplex.v1.UpdateDataAttributeRequest 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;
}
/**
*
*
* <pre>
* Update DataAttribute request.
* </pre>
*
* Protobuf type {@code google.cloud.dataplex.v1.UpdateDataAttributeRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.dataplex.v1.UpdateDataAttributeRequest)
com.google.cloud.dataplex.v1.UpdateDataAttributeRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.dataplex.v1.DataTaxonomyProto
.internal_static_google_cloud_dataplex_v1_UpdateDataAttributeRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.dataplex.v1.DataTaxonomyProto
.internal_static_google_cloud_dataplex_v1_UpdateDataAttributeRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.dataplex.v1.UpdateDataAttributeRequest.class,
com.google.cloud.dataplex.v1.UpdateDataAttributeRequest.Builder.class);
}
// Construct using com.google.cloud.dataplex.v1.UpdateDataAttributeRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getUpdateMaskFieldBuilder();
getDataAttributeFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
dataAttribute_ = null;
if (dataAttributeBuilder_ != null) {
dataAttributeBuilder_.dispose();
dataAttributeBuilder_ = null;
}
validateOnly_ = false;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.dataplex.v1.DataTaxonomyProto
.internal_static_google_cloud_dataplex_v1_UpdateDataAttributeRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.dataplex.v1.UpdateDataAttributeRequest getDefaultInstanceForType() {
return com.google.cloud.dataplex.v1.UpdateDataAttributeRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.dataplex.v1.UpdateDataAttributeRequest build() {
com.google.cloud.dataplex.v1.UpdateDataAttributeRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.dataplex.v1.UpdateDataAttributeRequest buildPartial() {
com.google.cloud.dataplex.v1.UpdateDataAttributeRequest result =
new com.google.cloud.dataplex.v1.UpdateDataAttributeRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.dataplex.v1.UpdateDataAttributeRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.dataAttribute_ =
dataAttributeBuilder_ == null ? dataAttribute_ : dataAttributeBuilder_.build();
to_bitField0_ |= 0x00000002;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.validateOnly_ = validateOnly_;
}
result.bitField0_ |= to_bitField0_;
}
@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.dataplex.v1.UpdateDataAttributeRequest) {
return mergeFrom((com.google.cloud.dataplex.v1.UpdateDataAttributeRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.dataplex.v1.UpdateDataAttributeRequest other) {
if (other == com.google.cloud.dataplex.v1.UpdateDataAttributeRequest.getDefaultInstance())
return this;
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
if (other.hasDataAttribute()) {
mergeDataAttribute(other.getDataAttribute());
}
if (other.getValidateOnly() != false) {
setValidateOnly(other.getValidateOnly());
}
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 10:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getDataAttributeFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
case 24:
{
validateOnly_ = input.readBool();
bitField0_ |= 0x00000004;
break;
} // case 24
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 com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000001);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* Required. Mask of fields to update.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
private com.google.cloud.dataplex.v1.DataAttribute dataAttribute_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.dataplex.v1.DataAttribute,
com.google.cloud.dataplex.v1.DataAttribute.Builder,
com.google.cloud.dataplex.v1.DataAttributeOrBuilder>
dataAttributeBuilder_;
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the dataAttribute field is set.
*/
public boolean hasDataAttribute() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The dataAttribute.
*/
public com.google.cloud.dataplex.v1.DataAttribute getDataAttribute() {
if (dataAttributeBuilder_ == null) {
return dataAttribute_ == null
? com.google.cloud.dataplex.v1.DataAttribute.getDefaultInstance()
: dataAttribute_;
} else {
return dataAttributeBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setDataAttribute(com.google.cloud.dataplex.v1.DataAttribute value) {
if (dataAttributeBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
dataAttribute_ = value;
} else {
dataAttributeBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setDataAttribute(
com.google.cloud.dataplex.v1.DataAttribute.Builder builderForValue) {
if (dataAttributeBuilder_ == null) {
dataAttribute_ = builderForValue.build();
} else {
dataAttributeBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeDataAttribute(com.google.cloud.dataplex.v1.DataAttribute value) {
if (dataAttributeBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& dataAttribute_ != null
&& dataAttribute_ != com.google.cloud.dataplex.v1.DataAttribute.getDefaultInstance()) {
getDataAttributeBuilder().mergeFrom(value);
} else {
dataAttribute_ = value;
}
} else {
dataAttributeBuilder_.mergeFrom(value);
}
if (dataAttribute_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearDataAttribute() {
bitField0_ = (bitField0_ & ~0x00000002);
dataAttribute_ = null;
if (dataAttributeBuilder_ != null) {
dataAttributeBuilder_.dispose();
dataAttributeBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.dataplex.v1.DataAttribute.Builder getDataAttributeBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getDataAttributeFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.dataplex.v1.DataAttributeOrBuilder getDataAttributeOrBuilder() {
if (dataAttributeBuilder_ != null) {
return dataAttributeBuilder_.getMessageOrBuilder();
} else {
return dataAttribute_ == null
? com.google.cloud.dataplex.v1.DataAttribute.getDefaultInstance()
: dataAttribute_;
}
}
/**
*
*
* <pre>
* Required. Only fields specified in `update_mask` are updated.
* </pre>
*
* <code>
* .google.cloud.dataplex.v1.DataAttribute data_attribute = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.dataplex.v1.DataAttribute,
com.google.cloud.dataplex.v1.DataAttribute.Builder,
com.google.cloud.dataplex.v1.DataAttributeOrBuilder>
getDataAttributeFieldBuilder() {
if (dataAttributeBuilder_ == null) {
dataAttributeBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.dataplex.v1.DataAttribute,
com.google.cloud.dataplex.v1.DataAttribute.Builder,
com.google.cloud.dataplex.v1.DataAttributeOrBuilder>(
getDataAttribute(), getParentForChildren(), isClean());
dataAttribute_ = null;
}
return dataAttributeBuilder_;
}
private boolean validateOnly_;
/**
*
*
* <pre>
* Optional. Only validate the request, but do not perform mutations.
* The default is false.
* </pre>
*
* <code>bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The validateOnly.
*/
@java.lang.Override
public boolean getValidateOnly() {
return validateOnly_;
}
/**
*
*
* <pre>
* Optional. Only validate the request, but do not perform mutations.
* The default is false.
* </pre>
*
* <code>bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The validateOnly to set.
* @return This builder for chaining.
*/
public Builder setValidateOnly(boolean value) {
validateOnly_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Only validate the request, but do not perform mutations.
* The default is false.
* </pre>
*
* <code>bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearValidateOnly() {
bitField0_ = (bitField0_ & ~0x00000004);
validateOnly_ = false;
onChanged();
return this;
}
@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.dataplex.v1.UpdateDataAttributeRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.dataplex.v1.UpdateDataAttributeRequest)
private static final com.google.cloud.dataplex.v1.UpdateDataAttributeRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.dataplex.v1.UpdateDataAttributeRequest();
}
public static com.google.cloud.dataplex.v1.UpdateDataAttributeRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateDataAttributeRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateDataAttributeRequest>() {
@java.lang.Override
public UpdateDataAttributeRequest 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<UpdateDataAttributeRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateDataAttributeRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.dataplex.v1.UpdateDataAttributeRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
hibernate/hibernate-search | 34,063 | integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/bytype/onetoone/ownedbycontaining/AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT.java | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association.bytype.onetoone.ownedbycontaining;
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import jakarta.persistence.Basic;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.OrderColumn;
import jakarta.persistence.Transient;
import org.hibernate.annotations.LazyGroup;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association.bytype.AbstractAutomaticIndexingSingleValuedAssociationBaseIT;
import org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association.bytype.ContainerPrimitives;
import org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association.bytype.accessor.MultiValuedPropertyAccessor;
import org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association.bytype.accessor.PropertyAccessor;
import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.AssociationInverseSide;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectPath;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper;
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.junit.jupiter.api.Test;
/**
* Test automatic indexing caused by single-valued association updates
* or by updates of associated (contained) entities,
* with a {@code @OneToOne} association owned by the containing side,
* and with lazy associations on the contained side.
*/
@BytecodeEnhanced // So that we can have lazy *ToOne associations
@EnhancementOptions(lazyLoading = true)
class AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT
extends AbstractAutomaticIndexingSingleValuedAssociationBaseIT<
AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT.IndexedEntity,
AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT.ContainingEntity,
AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT.ContainingEmbeddable,
AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT.ContainedEntity,
AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT.ContainedEmbeddable> {
public AutomaticIndexingOneToOneOwnedByContainingLazyOnContainedSideIT() {
super( IndexedEntity.PRIMITIVES, ContainingEntity.PRIMITIVES, ContainingEmbeddable.PRIMITIVES,
ContainedEntity.PRIMITIVES, ContainedEmbeddable.PRIMITIVES );
}
@Override
protected boolean isAssociationMultiValuedOnContainedSide() {
return false;
}
@Override
protected boolean isAssociationOwnedByContainedSide() {
return false;
}
@Override
protected boolean isAssociationLazyOnContainingSide() {
return false;
}
@Override
protected OrmSetupHelper.SetupContext additionalSetup(OrmSetupHelper.SetupContext setupContext) {
// Avoid problems with deep chains of eager associations in ORM 6
// See https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#fetch-circularity-determination
// See https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/lazy.20associations.20with.20ORM.206
setupContext.withProperty( AvailableSettings.MAX_FETCH_DEPTH, 1 );
// Necessary for BytecodeEnhancerRunner, see BytecodeEnhancementIT.setup
setupContext.withTcclLookupPrecedenceBefore();
return setupContext;
}
@Test
void testBytecodeEnhancementWorked() {
assertThat( ContainingEntity.class.getDeclaredMethods() )
.extracting( Method::getName )
.anyMatch( name -> name.startsWith( "$$_hibernate_" ) );
}
@Entity(name = "containing")
public static class ContainingEntity {
@Id
private Integer id;
private String nonIndexedField;
@OneToOne
private ContainingEntity parent;
@OneToOne(mappedBy = "parent")
@IndexedEmbedded(includePaths = {
"containedIndexedEmbedded.indexedField",
"containedIndexedEmbedded.indexedElementCollectionField",
"containedIndexedEmbedded.containedDerivedField",
"containedIndexedEmbeddedShallowReindexOnUpdate.indexedField",
"containedIndexedEmbeddedShallowReindexOnUpdate.indexedElementCollectionField",
"containedIndexedEmbeddedShallowReindexOnUpdate.containedDerivedField",
"containedIndexedEmbeddedNoReindexOnUpdate.indexedField",
"containedIndexedEmbeddedNoReindexOnUpdate.indexedElementCollectionField",
"containedIndexedEmbeddedNoReindexOnUpdate.containedDerivedField",
"containedIndexedEmbeddedWithCast.indexedField",
"embeddedAssociations.containedIndexedEmbedded.indexedField",
"embeddedAssociations.containedIndexedEmbedded.indexedElementCollectionField",
"embeddedAssociations.containedIndexedEmbedded.containedDerivedField",
"elementCollectionAssociations.containedIndexedEmbedded.indexedField",
"elementCollectionAssociations.containedIndexedEmbedded.indexedElementCollectionField",
"elementCollectionAssociations.containedIndexedEmbedded.containedDerivedField",
"crossEntityDerivedField"
})
private ContainingEntity child;
@OneToOne
@IndexedEmbedded(includePaths = { "indexedField", "indexedElementCollectionField", "containedDerivedField" })
private ContainedEntity containedIndexedEmbedded;
@OneToOne
private ContainedEntity containedNonIndexedEmbedded;
@OneToOne
@JoinColumn(name = "CIndexedEmbeddedSROU")
@IndexedEmbedded(includePaths = { "indexedField", "indexedElementCollectionField", "containedDerivedField" })
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
private ContainedEntity containedIndexedEmbeddedShallowReindexOnUpdate;
@OneToOne
@JoinColumn(name = "CIndexedEmbeddedNROU")
@IndexedEmbedded(includePaths = { "indexedField", "indexedElementCollectionField", "containedDerivedField" })
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.NO)
private ContainedEntity containedIndexedEmbeddedNoReindexOnUpdate;
@OneToOne
@JoinColumn(name = "CCrossEntityDerived")
private ContainedEntity containedUsedInCrossEntityDerivedProperty;
@OneToOne(targetEntity = ContainedEntity.class)
@JoinColumn(name = "CIndexedEmbeddedCast")
@IndexedEmbedded(includePaths = { "indexedField" }, targetType = ContainedEntity.class)
private Object containedIndexedEmbeddedWithCast;
@IndexedEmbedded
@Embedded
private ContainingEmbeddable embeddedAssociations;
@IndexedEmbedded
@ElementCollection
@Embedded
@OrderColumn(name = "idx")
@CollectionTable(name = "i_ECAssoc")
private List<ContainingEmbeddable> elementCollectionAssociations = new ArrayList<>();
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNonIndexedField() {
return nonIndexedField;
}
public void setNonIndexedField(String nonIndexedField) {
this.nonIndexedField = nonIndexedField;
}
public ContainingEntity getParent() {
return parent;
}
public void setParent(ContainingEntity parent) {
this.parent = parent;
}
public ContainingEntity getChild() {
return child;
}
public void setChild(ContainingEntity child) {
this.child = child;
}
public ContainedEntity getContainedIndexedEmbedded() {
return containedIndexedEmbedded;
}
public void setContainedIndexedEmbedded(ContainedEntity containedIndexedEmbedded) {
this.containedIndexedEmbedded = containedIndexedEmbedded;
}
public ContainedEntity getContainedNonIndexedEmbedded() {
return containedNonIndexedEmbedded;
}
public void setContainedNonIndexedEmbedded(ContainedEntity containedNonIndexedEmbedded) {
this.containedNonIndexedEmbedded = containedNonIndexedEmbedded;
}
public ContainedEntity getContainedIndexedEmbeddedShallowReindexOnUpdate() {
return containedIndexedEmbeddedShallowReindexOnUpdate;
}
public void setContainedIndexedEmbeddedShallowReindexOnUpdate(
ContainedEntity containedIndexedEmbeddedShallowReindexOnUpdate) {
this.containedIndexedEmbeddedShallowReindexOnUpdate = containedIndexedEmbeddedShallowReindexOnUpdate;
}
public ContainedEntity getContainedIndexedEmbeddedNoReindexOnUpdate() {
return containedIndexedEmbeddedNoReindexOnUpdate;
}
public void setContainedIndexedEmbeddedNoReindexOnUpdate(
ContainedEntity containedIndexedEmbeddedNoReindexOnUpdate) {
this.containedIndexedEmbeddedNoReindexOnUpdate = containedIndexedEmbeddedNoReindexOnUpdate;
}
public ContainedEntity getContainedUsedInCrossEntityDerivedProperty() {
return containedUsedInCrossEntityDerivedProperty;
}
public void setContainedUsedInCrossEntityDerivedProperty(
ContainedEntity containedUsedInCrossEntityDerivedProperty) {
this.containedUsedInCrossEntityDerivedProperty = containedUsedInCrossEntityDerivedProperty;
}
public Object getContainedIndexedEmbeddedWithCast() {
return containedIndexedEmbeddedWithCast;
}
public void setContainedIndexedEmbeddedWithCast(Object containedIndexedEmbeddedWithCast) {
this.containedIndexedEmbeddedWithCast = containedIndexedEmbeddedWithCast;
}
public ContainingEmbeddable getEmbeddedAssociations() {
return embeddedAssociations;
}
public void setEmbeddedAssociations(ContainingEmbeddable embeddedAssociations) {
this.embeddedAssociations = embeddedAssociations;
}
public List<ContainingEmbeddable> getElementCollectionAssociations() {
return elementCollectionAssociations;
}
@Transient
@GenericField
@IndexingDependency(derivedFrom = {
@ObjectPath({
@PropertyValue(propertyName = "containedUsedInCrossEntityDerivedProperty"),
@PropertyValue(propertyName = "fieldUsedInCrossEntityDerivedField1")
}),
@ObjectPath({
@PropertyValue(propertyName = "containedUsedInCrossEntityDerivedProperty"),
@PropertyValue(propertyName = "fieldUsedInCrossEntityDerivedField2")
})
})
public Optional<String> getCrossEntityDerivedField() {
return containedUsedInCrossEntityDerivedProperty == null
? Optional.empty()
: computeDerived( Stream.of(
containedUsedInCrossEntityDerivedProperty.getFieldUsedInCrossEntityDerivedField1(),
containedUsedInCrossEntityDerivedProperty.getFieldUsedInCrossEntityDerivedField2()
) );
}
static final ContainingEntityPrimitives<ContainingEntity, ContainingEmbeddable, ContainedEntity> PRIMITIVES =
new ContainingEntityPrimitives<ContainingEntity, ContainingEmbeddable, ContainedEntity>() {
@Override
public Class<ContainingEntity> entityClass() {
return ContainingEntity.class;
}
@Override
public ContainingEntity newInstance(int id) {
ContainingEntity entity = new ContainingEntity();
entity.setId( id );
return entity;
}
@Override
public PropertyAccessor<ContainingEntity, ContainingEntity> child() {
return PropertyAccessor.create( ContainingEntity::setChild );
}
@Override
public PropertyAccessor<ContainingEntity, ContainingEntity> parent() {
return PropertyAccessor.create( ContainingEntity::setParent );
}
@Override
public PropertyAccessor<ContainingEntity, ContainedEntity> containedIndexedEmbedded() {
return PropertyAccessor.create( ContainingEntity::setContainedIndexedEmbedded,
ContainingEntity::getContainedIndexedEmbedded );
}
@Override
public PropertyAccessor<ContainingEntity, ContainedEntity> containedNonIndexedEmbedded() {
return PropertyAccessor.create( ContainingEntity::setContainedNonIndexedEmbedded,
ContainingEntity::getContainedNonIndexedEmbedded );
}
@Override
public PropertyAccessor<ContainingEntity,
ContainedEntity> containedIndexedEmbeddedShallowReindexOnUpdate() {
return PropertyAccessor.create( ContainingEntity::setContainedIndexedEmbeddedShallowReindexOnUpdate,
ContainingEntity::getContainedIndexedEmbeddedShallowReindexOnUpdate );
}
@Override
public PropertyAccessor<ContainingEntity, ContainedEntity> containedIndexedEmbeddedNoReindexOnUpdate() {
return PropertyAccessor.create( ContainingEntity::setContainedIndexedEmbeddedNoReindexOnUpdate,
ContainingEntity::getContainedIndexedEmbeddedNoReindexOnUpdate );
}
@Override
public PropertyAccessor<ContainingEntity, ContainedEntity> containedUsedInCrossEntityDerivedProperty() {
return PropertyAccessor.create( ContainingEntity::setContainedUsedInCrossEntityDerivedProperty,
ContainingEntity::getContainedUsedInCrossEntityDerivedProperty );
}
@Override
public PropertyAccessor<ContainingEntity, ContainedEntity> containedIndexedEmbeddedWithCast() {
return PropertyAccessor.create( ContainingEntity::setContainedIndexedEmbeddedWithCast );
}
@Override
public PropertyAccessor<ContainingEntity, ContainingEmbeddable> embeddedAssociations() {
return PropertyAccessor.create( ContainingEntity::setEmbeddedAssociations,
ContainingEntity::getEmbeddedAssociations );
}
@Override
public MultiValuedPropertyAccessor<ContainingEntity,
ContainingEmbeddable,
List<ContainingEmbeddable>> elementCollectionAssociations() {
return MultiValuedPropertyAccessor.create( ContainerPrimitives.collection(),
ContainingEntity::getElementCollectionAssociations );
}
@Override
public PropertyAccessor<ContainingEntity, String> nonIndexedField() {
return PropertyAccessor.create( ContainingEntity::setNonIndexedField );
}
};
}
public static class ContainingEmbeddable {
@OneToOne
@JoinColumn(name = "CEmbIdxEmbedded")
@IndexedEmbedded(includePaths = { "indexedField", "indexedElementCollectionField", "containedDerivedField" },
name = "containedIndexedEmbedded")
private ContainedEntity containedIndexedEmbedded;
@OneToOne
@JoinColumn(name = "CEmbNonIdxEmbedded")
private ContainedEntity containedNonIndexedEmbedded;
public ContainedEntity getContainedIndexedEmbedded() {
return containedIndexedEmbedded;
}
public void setContainedIndexedEmbedded(ContainedEntity containedIndexedEmbedded) {
this.containedIndexedEmbedded = containedIndexedEmbedded;
}
public ContainedEntity getContainedNonIndexedEmbedded() {
return containedNonIndexedEmbedded;
}
public void setContainedNonIndexedEmbedded(ContainedEntity containedNonIndexedEmbedded) {
this.containedNonIndexedEmbedded = containedNonIndexedEmbedded;
}
static final ContainingEmbeddablePrimitives<ContainingEmbeddable, ContainedEntity> PRIMITIVES =
new ContainingEmbeddablePrimitives<ContainingEmbeddable, ContainedEntity>() {
@Override
public ContainingEmbeddable newInstance() {
return new ContainingEmbeddable();
}
@Override
public PropertyAccessor<ContainingEmbeddable, ContainedEntity> containedIndexedEmbedded() {
return PropertyAccessor.create( ContainingEmbeddable::setContainedIndexedEmbedded,
ContainingEmbeddable::getContainedIndexedEmbedded
);
}
@Override
public PropertyAccessor<ContainingEmbeddable, ContainedEntity> containedNonIndexedEmbedded() {
return PropertyAccessor.create( ContainingEmbeddable::setContainedNonIndexedEmbedded,
ContainingEmbeddable::getContainedNonIndexedEmbedded
);
}
};
}
@Entity(name = "indexed")
@Indexed(index = IndexedEntity.INDEX)
public static class IndexedEntity extends ContainingEntity {
static final String INDEX = "IndexedEntity";
static final IndexedEntityPrimitives<IndexedEntity> PRIMITIVES = new IndexedEntityPrimitives<IndexedEntity>() {
@Override
public Class<IndexedEntity> entityClass() {
return IndexedEntity.class;
}
@Override
public String indexName() {
return IndexedEntity.INDEX;
}
@Override
public IndexedEntity newInstance(int id) {
IndexedEntity entity = new IndexedEntity();
entity.setId( id );
return entity;
}
};
}
@Entity(name = "contained")
public static class ContainedEntity {
@Id
private Integer id;
@OneToOne(mappedBy = "containedIndexedEmbedded", fetch = FetchType.LAZY)
@LazyGroup("containingAsIndexedEmbedded")
private ContainingEntity containingAsIndexedEmbedded;
@OneToOne(mappedBy = "containedNonIndexedEmbedded", fetch = FetchType.LAZY)
@LazyGroup("containingAsNonIndexedEmbedded")
private ContainingEntity containingAsNonIndexedEmbedded;
@OneToOne(mappedBy = "containedIndexedEmbeddedShallowReindexOnUpdate", fetch = FetchType.LAZY)
@LazyGroup("containingAsIndexedEmbeddedShallowReindexOnUpdate")
private ContainingEntity containingAsIndexedEmbeddedShallowReindexOnUpdate;
@OneToOne(mappedBy = "containedIndexedEmbeddedNoReindexOnUpdate", fetch = FetchType.LAZY)
@LazyGroup("containingAsIndexedEmbeddedNoReindexOnUpdate")
private ContainingEntity containingAsIndexedEmbeddedNoReindexOnUpdate;
@OneToOne(mappedBy = "containedUsedInCrossEntityDerivedProperty", fetch = FetchType.LAZY)
@LazyGroup("containingAsUsedInCrossEntityDerivedProperty")
private ContainingEntity containingAsUsedInCrossEntityDerivedProperty;
@OneToOne(mappedBy = "containedIndexedEmbeddedWithCast", targetEntity = ContainingEntity.class, fetch = FetchType.LAZY)
@LazyGroup("containingAsIndexedEmbeddedWithCast")
private Object containingAsIndexedEmbeddedWithCast;
@Embedded
private ContainedEmbeddable embeddedAssociations;
/*
* No mappedBy here. The inverse side of associations within an element collection cannot use mappedBy.
* If they do, Hibernate ORM will fail (throw an exception) while attempting to walk down the mappedBy path,
* because it assumes the prefix of that path is an embeddable,
* and in this case it is a List.
* TODO use mappedBy when the above gets fixed in Hibernate ORM
*/
@ManyToOne(fetch = FetchType.LAZY)
@LazyGroup("containingAsElementCollectionAssociationsIndexedEmbedded")
@JoinColumn(name = "CECAssocIdxEmb")
@AssociationInverseSide(inversePath = @ObjectPath({
@PropertyValue(propertyName = "elementCollectionAssociations"),
@PropertyValue(propertyName = "containedIndexedEmbedded")
}))
private ContainingEntity containingAsElementCollectionAssociationsIndexedEmbedded;
/*
* No mappedBy here. Same reason as just above.
* TODO use mappedBy when the above gets fixed in Hibernate ORM
*/
@ManyToOne(fetch = FetchType.LAZY)
@LazyGroup("containingAsElementCollectionAssociationsNonIndexedEmbedded")
@JoinColumn(name = "CECAssocNonIdxEmb")
@AssociationInverseSide(inversePath = @ObjectPath({
@PropertyValue(propertyName = "elementCollectionAssociations"),
@PropertyValue(propertyName = "containedNonIndexedEmbedded")
}))
private ContainingEntity containingAsElementCollectionAssociationsNonIndexedEmbedded;
@Basic
@GenericField
private String indexedField;
@ElementCollection
@OrderColumn(name = "idx")
@CollectionTable(name = "indexedECF")
@GenericField
private List<String> indexedElementCollectionField = new ArrayList<>();
@Basic
@GenericField
// Keep this annotation, it should be ignored because the field is not included in the @IndexedEmbedded
private String nonIndexedField;
@ElementCollection
@OrderColumn(name = "idx")
@CollectionTable(name = "nonIndexedECF")
@Column(name = "nonIndexedECF")
@GenericField
// Keep this annotation, it should be ignored because the field is not included in the @IndexedEmbedded
private List<String> nonIndexedElementCollectionField = new ArrayList<>();
@Basic // Do not annotate with @GenericField, this would make the test pointless
@Column(name = "FUIContainedDF1")
private String fieldUsedInContainedDerivedField1;
@Basic // Do not annotate with @GenericField, this would make the test pointless
@Column(name = "FUIContainedDF2")
private String fieldUsedInContainedDerivedField2;
@Basic // Do not annotate with @GenericField, this would make the test pointless
@Column(name = "FUICrossEntityDF1")
private String fieldUsedInCrossEntityDerivedField1;
@Basic // Do not annotate with @GenericField, this would make the test pointless
@Column(name = "FUICrossEntityDF2")
private String fieldUsedInCrossEntityDerivedField2;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public ContainingEntity getContainingAsIndexedEmbedded() {
return containingAsIndexedEmbedded;
}
public void setContainingAsIndexedEmbedded(ContainingEntity containingAsIndexedEmbedded) {
this.containingAsIndexedEmbedded = containingAsIndexedEmbedded;
}
public ContainingEntity getContainingAsNonIndexedEmbedded() {
return containingAsNonIndexedEmbedded;
}
public void setContainingAsNonIndexedEmbedded(ContainingEntity containingAsNonIndexedEmbedded) {
this.containingAsNonIndexedEmbedded = containingAsNonIndexedEmbedded;
}
public ContainingEntity getContainingAsIndexedEmbeddedShallowReindexOnUpdate() {
return containingAsIndexedEmbeddedShallowReindexOnUpdate;
}
public void setContainingAsIndexedEmbeddedShallowReindexOnUpdate(
ContainingEntity containingAsIndexedEmbeddedShallowReindexOnUpdate) {
this.containingAsIndexedEmbeddedShallowReindexOnUpdate = containingAsIndexedEmbeddedShallowReindexOnUpdate;
}
public ContainingEntity getContainingAsIndexedEmbeddedNoReindexOnUpdate() {
return containingAsIndexedEmbeddedNoReindexOnUpdate;
}
public void setContainingAsIndexedEmbeddedNoReindexOnUpdate(
ContainingEntity containingAsIndexedEmbeddedNoReindexOnUpdate) {
this.containingAsIndexedEmbeddedNoReindexOnUpdate = containingAsIndexedEmbeddedNoReindexOnUpdate;
}
public ContainingEntity getContainingAsUsedInCrossEntityDerivedProperty() {
return containingAsUsedInCrossEntityDerivedProperty;
}
public void setContainingAsUsedInCrossEntityDerivedProperty(
ContainingEntity containingAsUsedInCrossEntityDerivedProperty) {
this.containingAsUsedInCrossEntityDerivedProperty = containingAsUsedInCrossEntityDerivedProperty;
}
public Object getContainingAsIndexedEmbeddedWithCast() {
return containingAsIndexedEmbeddedWithCast;
}
public void setContainingAsIndexedEmbeddedWithCast(Object containingAsIndexedEmbeddedWithCast) {
this.containingAsIndexedEmbeddedWithCast = containingAsIndexedEmbeddedWithCast;
}
public ContainedEmbeddable getEmbeddedAssociations() {
return embeddedAssociations;
}
public void setEmbeddedAssociations(ContainedEmbeddable embeddedAssociations) {
this.embeddedAssociations = embeddedAssociations;
}
public ContainingEntity getContainingAsElementCollectionAssociationsIndexedEmbedded() {
return containingAsElementCollectionAssociationsIndexedEmbedded;
}
public void setContainingAsElementCollectionAssociationsIndexedEmbedded(
ContainingEntity containingAsElementCollectionAssociationsIndexedEmbedded) {
this.containingAsElementCollectionAssociationsIndexedEmbedded =
containingAsElementCollectionAssociationsIndexedEmbedded;
}
public ContainingEntity getContainingAsElementCollectionAssociationsNonIndexedEmbedded() {
return containingAsElementCollectionAssociationsNonIndexedEmbedded;
}
public void setContainingAsElementCollectionAssociationsNonIndexedEmbedded(
ContainingEntity containingAsElementCollectionAssociationsNonIndexedEmbedded) {
this.containingAsElementCollectionAssociationsNonIndexedEmbedded =
containingAsElementCollectionAssociationsNonIndexedEmbedded;
}
public String getIndexedField() {
return indexedField;
}
public void setIndexedField(String indexedField) {
this.indexedField = indexedField;
}
public List<String> getIndexedElementCollectionField() {
return indexedElementCollectionField;
}
public void setIndexedElementCollectionField(List<String> indexedElementCollectionField) {
this.indexedElementCollectionField = indexedElementCollectionField;
}
public String getNonIndexedField() {
return nonIndexedField;
}
public void setNonIndexedField(String nonIndexedField) {
this.nonIndexedField = nonIndexedField;
}
public List<String> getNonIndexedElementCollectionField() {
return nonIndexedElementCollectionField;
}
public void setNonIndexedElementCollectionField(List<String> nonIndexedElementCollectionField) {
this.nonIndexedElementCollectionField = nonIndexedElementCollectionField;
}
public String getFieldUsedInContainedDerivedField1() {
return fieldUsedInContainedDerivedField1;
}
public void setFieldUsedInContainedDerivedField1(String fieldUsedInContainedDerivedField1) {
this.fieldUsedInContainedDerivedField1 = fieldUsedInContainedDerivedField1;
}
public String getFieldUsedInContainedDerivedField2() {
return fieldUsedInContainedDerivedField2;
}
public void setFieldUsedInContainedDerivedField2(String fieldUsedInContainedDerivedField2) {
this.fieldUsedInContainedDerivedField2 = fieldUsedInContainedDerivedField2;
}
public String getFieldUsedInCrossEntityDerivedField1() {
return fieldUsedInCrossEntityDerivedField1;
}
public void setFieldUsedInCrossEntityDerivedField1(String fieldUsedInCrossEntityDerivedField1) {
this.fieldUsedInCrossEntityDerivedField1 = fieldUsedInCrossEntityDerivedField1;
}
public String getFieldUsedInCrossEntityDerivedField2() {
return fieldUsedInCrossEntityDerivedField2;
}
public void setFieldUsedInCrossEntityDerivedField2(String fieldUsedInCrossEntityDerivedField2) {
this.fieldUsedInCrossEntityDerivedField2 = fieldUsedInCrossEntityDerivedField2;
}
@Transient
@GenericField
@IndexingDependency(derivedFrom = {
@ObjectPath(@PropertyValue(propertyName = "fieldUsedInContainedDerivedField1")),
@ObjectPath(@PropertyValue(propertyName = "fieldUsedInContainedDerivedField2"))
})
public Optional<String> getContainedDerivedField() {
return computeDerived( Stream.of( fieldUsedInContainedDerivedField1, fieldUsedInContainedDerivedField2 ) );
}
static ContainedEntityPrimitives<ContainedEntity, ContainedEmbeddable, ContainingEntity> PRIMITIVES =
new ContainedEntityPrimitives<ContainedEntity, ContainedEmbeddable, ContainingEntity>() {
@Override
public Class<ContainedEntity> entityClass() {
return ContainedEntity.class;
}
@Override
public ContainedEntity newInstance(int id) {
ContainedEntity entity = new ContainedEntity();
entity.setId( id );
return entity;
}
@Override
public PropertyAccessor<ContainedEntity, ContainingEntity> containingAsIndexedEmbedded() {
return PropertyAccessor.create( ContainedEntity::setContainingAsIndexedEmbedded,
ContainedEntity::getContainingAsIndexedEmbedded );
}
@Override
public PropertyAccessor<ContainedEntity, ContainingEntity> containingAsNonIndexedEmbedded() {
return PropertyAccessor.create( ContainedEntity::setContainingAsNonIndexedEmbedded,
ContainedEntity::getContainingAsNonIndexedEmbedded );
}
@Override
public PropertyAccessor<ContainedEntity,
ContainingEntity> containingAsIndexedEmbeddedShallowReindexOnUpdate() {
return PropertyAccessor.create( ContainedEntity::setContainingAsIndexedEmbeddedShallowReindexOnUpdate,
ContainedEntity::getContainingAsIndexedEmbeddedShallowReindexOnUpdate );
}
@Override
public PropertyAccessor<ContainedEntity, ContainingEntity> containingAsIndexedEmbeddedNoReindexOnUpdate() {
return PropertyAccessor.create( ContainedEntity::setContainingAsIndexedEmbeddedNoReindexOnUpdate,
ContainedEntity::getContainingAsIndexedEmbeddedNoReindexOnUpdate );
}
@Override
public PropertyAccessor<ContainedEntity, ContainingEntity> containingAsUsedInCrossEntityDerivedProperty() {
return PropertyAccessor.create( ContainedEntity::setContainingAsUsedInCrossEntityDerivedProperty,
ContainedEntity::getContainingAsUsedInCrossEntityDerivedProperty );
}
@Override
public PropertyAccessor<ContainedEntity, ContainingEntity> containingAsIndexedEmbeddedWithCast() {
return PropertyAccessor.create( ContainedEntity::setContainingAsIndexedEmbeddedWithCast );
}
@Override
public PropertyAccessor<ContainedEntity, ContainedEmbeddable> embeddedAssociations() {
return PropertyAccessor.create( ContainedEntity::setEmbeddedAssociations,
ContainedEntity::getEmbeddedAssociations );
}
@Override
public PropertyAccessor<ContainedEntity,
ContainingEntity> containingAsElementCollectionAssociationsIndexedEmbedded() {
return PropertyAccessor.create(
ContainedEntity::setContainingAsElementCollectionAssociationsIndexedEmbedded,
ContainedEntity::getContainingAsElementCollectionAssociationsIndexedEmbedded );
}
@Override
public PropertyAccessor<ContainedEntity,
ContainingEntity> containingAsElementCollectionAssociationsNonIndexedEmbedded() {
return PropertyAccessor.create(
ContainedEntity::setContainingAsElementCollectionAssociationsNonIndexedEmbedded,
ContainedEntity::getContainingAsElementCollectionAssociationsNonIndexedEmbedded );
}
@Override
public PropertyAccessor<ContainedEntity, String> indexedField() {
return PropertyAccessor.create( ContainedEntity::setIndexedField );
}
@Override
public PropertyAccessor<ContainedEntity, String> nonIndexedField() {
return PropertyAccessor.create( ContainedEntity::setNonIndexedField );
}
@Override
public MultiValuedPropertyAccessor<ContainedEntity, String, List<String>> indexedElementCollectionField() {
return MultiValuedPropertyAccessor.create( ContainerPrimitives.collection(),
ContainedEntity::getIndexedElementCollectionField,
ContainedEntity::setIndexedElementCollectionField );
}
@Override
public MultiValuedPropertyAccessor<ContainedEntity,
String,
List<String>> nonIndexedElementCollectionField() {
return MultiValuedPropertyAccessor.create( ContainerPrimitives.collection(),
ContainedEntity::getNonIndexedElementCollectionField,
ContainedEntity::setNonIndexedElementCollectionField );
}
@Override
public PropertyAccessor<ContainedEntity, String> fieldUsedInContainedDerivedField1() {
return PropertyAccessor.create( ContainedEntity::setFieldUsedInContainedDerivedField1 );
}
@Override
public PropertyAccessor<ContainedEntity, String> fieldUsedInContainedDerivedField2() {
return PropertyAccessor.create( ContainedEntity::setFieldUsedInContainedDerivedField2 );
}
@Override
public PropertyAccessor<ContainedEntity, String> fieldUsedInCrossEntityDerivedField1() {
return PropertyAccessor.create( ContainedEntity::setFieldUsedInCrossEntityDerivedField1 );
}
@Override
public PropertyAccessor<ContainedEntity, String> fieldUsedInCrossEntityDerivedField2() {
return PropertyAccessor.create( ContainedEntity::setFieldUsedInCrossEntityDerivedField2 );
}
};
}
public static class ContainedEmbeddable {
@OneToOne(mappedBy = "embeddedAssociations.containedIndexedEmbedded", fetch = FetchType.LAZY)
@LazyGroup("embeddable_containingAsIndexedEmbedded")
private ContainingEntity containingAsIndexedEmbedded;
@OneToOne(mappedBy = "embeddedAssociations.containedNonIndexedEmbedded", fetch = FetchType.LAZY)
@LazyGroup("embeddable_containingAsNonIndexedEmbedded")
private ContainingEntity containingAsNonIndexedEmbedded;
public ContainingEntity getContainingAsIndexedEmbedded() {
return containingAsIndexedEmbedded;
}
public void setContainingAsIndexedEmbedded(ContainingEntity containingAsIndexedEmbedded) {
this.containingAsIndexedEmbedded = containingAsIndexedEmbedded;
}
public ContainingEntity getContainingAsNonIndexedEmbedded() {
return containingAsNonIndexedEmbedded;
}
public void setContainingAsNonIndexedEmbedded(ContainingEntity containingAsNonIndexedEmbedded) {
this.containingAsNonIndexedEmbedded = containingAsNonIndexedEmbedded;
}
static ContainedEmbeddablePrimitives<ContainedEmbeddable, ContainingEntity> PRIMITIVES =
new ContainedEmbeddablePrimitives<ContainedEmbeddable, ContainingEntity>() {
@Override
public ContainedEmbeddable newInstance() {
return new ContainedEmbeddable();
}
@Override
public PropertyAccessor<ContainedEmbeddable, ContainingEntity> containingAsIndexedEmbedded() {
return PropertyAccessor.create( ContainedEmbeddable::setContainingAsIndexedEmbedded,
ContainedEmbeddable::getContainingAsIndexedEmbedded
);
}
@Override
public PropertyAccessor<ContainedEmbeddable, ContainingEntity> containingAsNonIndexedEmbedded() {
return PropertyAccessor.create( ContainedEmbeddable::setContainingAsIndexedEmbedded,
ContainedEmbeddable::getContainingAsIndexedEmbedded
);
}
};
}
}
|
apache/tomcat | 36,509 | java/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.tribes.group.interceptors;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.catalina.tribes.Channel;
import org.apache.catalina.tribes.ChannelException;
import org.apache.catalina.tribes.ChannelInterceptor;
import org.apache.catalina.tribes.ChannelMessage;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.UniqueId;
import org.apache.catalina.tribes.group.AbsoluteOrder;
import org.apache.catalina.tribes.group.ChannelInterceptorBase;
import org.apache.catalina.tribes.group.InterceptorPayload;
import org.apache.catalina.tribes.io.ChannelData;
import org.apache.catalina.tribes.io.XByteBuffer;
import org.apache.catalina.tribes.membership.MemberImpl;
import org.apache.catalina.tribes.membership.Membership;
import org.apache.catalina.tribes.util.Arrays;
import org.apache.catalina.tribes.util.StringManager;
import org.apache.catalina.tribes.util.UUIDGenerator;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
* <p>
* Title: Auto merging leader election algorithm
* </p>
* <p>
* Description: Implementation of a simple coordinator algorithm that not only selects a coordinator, it also merges
* groups automatically when members are discovered that weren't part of the
* </p>
* <p>
* This algorithm is non blocking meaning it allows for transactions while the coordination phase is going on
* </p>
* <p>
* This implementation is based on a home brewed algorithm that uses the AbsoluteOrder of a membership to pass a token
* ring of the current membership.<br>
* This is not the same as just using AbsoluteOrder! Consider the following scenario:<br>
* Nodes, A,B,C,D,E on a network, in that priority. AbsoluteOrder will only work if all nodes are receiving pings from
* all the other nodes. meaning, that node{i} receives pings from node{all}-node{i}<br>
* but the following could happen if a multicast problem occurs. A has members {B,C,D}<br>
* B has members {A,C}<br>
* C has members {D,E}<br>
* D has members {A,B,C,E}<br>
* E has members {A,C,D}<br>
* Because the default Tribes membership implementation, relies on the multicast packets to arrive at all nodes
* correctly, there is nothing guaranteeing that it will.<br>
* <br>
* To best explain how this algorithm works, lets take the above example: For simplicity we assume that a send operation
* is O(1) for all nodes, although this algorithm will work where messages overlap, as they all depend on absolute
* order<br>
* Scenario 1: A,B,C,D,E all come online at the same time Eval phase, A thinks of itself as leader, B thinks of A as
* leader, C thinks of itself as leader, D,E think of A as leader<br>
* Token phase:<br>
* (1) A sends out a message X{A-ldr, A-src, mbrs-A,B,C,D} to B where X is the id for the message(and the view)<br>
* (1) C sends out a message Y{C-ldr, C-src, mbrs-C,D,E} to D where Y is the id for the message(and the view)<br>
* (2) B receives X{A-ldr, A-src, mbrs-A,B,C,D}, sends X{A-ldr, A-src, mbrs-A,B,C,D} to C <br>
* (2) D receives Y{C-ldr, C-src, mbrs-C,D,E} D is aware of A,B, sends Y{A-ldr, C-src, mbrs-A,B,C,D,E} to E<br>
* (3) C receives X{A-ldr, A-src, mbrs-A,B,C,D}, sends X{A-ldr, A-src, mbrs-A,B,C,D,E} to D<br>
* (3) E receives Y{A-ldr, C-src, mbrs-A,B,C,D,E} sends Y{A-ldr, C-src, mbrs-A,B,C,D,E} to A<br>
* (4) D receives X{A-ldr, A-src, mbrs-A,B,C,D,E} sends sends X{A-ldr, A-src, mbrs-A,B,C,D,E} to A<br>
* (4) A receives Y{A-ldr, C-src, mbrs-A,B,C,D,E}, holds the message, add E to its list of members<br>
* (5) A receives X{A-ldr, A-src, mbrs-A,B,C,D,E} <br>
* At this point, the state looks like<br>
* A - {A-ldr, mbrs-A,B,C,D,E, id=X}<br>
* B - {A-ldr, mbrs-A,B,C,D, id=X}<br>
* C - {A-ldr, mbrs-A,B,C,D,E, id=X}<br>
* D - {A-ldr, mbrs-A,B,C,D,E, id=X}<br>
* E - {A-ldr, mbrs-A,B,C,D,E, id=Y}<br>
* <br>
* A message doesn't stop until it reaches its original sender, unless its dropped by a higher leader. As you can see, E
* still thinks the viewId=Y, which is not correct. But at this point we have arrived at the same membership and all
* nodes are informed of each other.<br>
* To synchronize the rest we simply perform the following check at A when A receives X:<br>
* Original X{A-ldr, A-src, mbrs-A,B,C,D} == Arrived X{A-ldr, A-src, mbrs-A,B,C,D,E}<br>
* Since the condition is false, A, will resend the token, and A sends X{A-ldr, A-src, mbrs-A,B,C,D,E} to B When A
* receives X again, the token is complete. <br>
* Optionally, A can send a message X{A-ldr, A-src, mbrs-A,B,C,D,E confirmed} to A,B,C,D,E who then install and accept
* the view.
* </p>
* <p>
* Let's assume that C1 arrives, C1 has lower priority than C, but higher priority than D.<br>
* Let's also assume that C1 sees the following view {B,D,E}<br>
* C1 waits for a token to arrive. When the token arrives, the same scenario as above will happen.<br>
* In the scenario where C1 sees {D,E} and A,B,C cannot see C1, no token will ever arrive.<br>
* In this case, C1 sends a Z{C1-ldr, C1-src, mbrs-C1,D,E} to D<br>
* D receives Z{C1-ldr, C1-src, mbrs-C1,D,E} and sends Z{A-ldr, C1-src, mbrs-A,B,C,C1,D,E} to E<br>
* E receives Z{A-ldr, C1-src, mbrs-A,B,C,C1,D,E} and sends it to A<br>
* A sends Z{A-ldr, A-src, mbrs-A,B,C,C1,D,E} to B and the chain continues until A receives the token again. At that
* time A optionally sends out Z{A-ldr, A-src, mbrs-A,B,C,C1,D,E, confirmed} to A,B,C,C1,D,E
* </p>
* <p>
* To ensure that the view gets implemented at all nodes at the same time, A will send out a VIEW_CONF message, this is
* the 'confirmed' message that is optional above.
* <p>
* Ideally, the interceptor below this one would be the TcpFailureDetector to ensure correct memberships
* </p>
* <p>
* The example above, of course can be simplified with a finite statemachine:<br>
* But I suck at writing state machines, my head gets all confused. One day I will document this algorithm though.<br>
* Maybe I'll do a state diagram :)
* </p>
* <h2>State Diagrams</h2>
* <a href="https://people.apache.org/~fhanik/tribes/docs/leader-election-initiate-election.jpg">Initiate an
* election</a><br>
* <br>
* <a href="https://people.apache.org/~fhanik/tribes/docs/leader-election-message-arrives.jpg">Receive an election
* message</a><br>
* <br>
*/
public class NonBlockingCoordinator extends ChannelInterceptorBase {
private static final Log log = LogFactory.getLog(NonBlockingCoordinator.class);
protected static final StringManager sm = StringManager.getManager(NonBlockingCoordinator.class);
/**
* header for a coordination message
*/
protected static final byte[] COORD_HEADER =
new byte[] { -86, 38, -34, -29, -98, 90, 65, 63, -81, -122, -6, -110, 99, -54, 13, 63 };
/**
* Coordination request
*/
protected static final byte[] COORD_REQUEST =
new byte[] { 104, -95, -92, -42, 114, -36, 71, -19, -79, 20, 122, 101, -1, -48, -49, 30 };
/**
* Coordination confirmation, for blocking installations
*/
protected static final byte[] COORD_CONF =
new byte[] { 67, 88, 107, -86, 69, 23, 76, -70, -91, -23, -87, -25, -125, 86, 75, 20 };
/**
* Alive message
*/
protected static final byte[] COORD_ALIVE = new byte[] { 79, -121, -25, -15, -59, 5, 64, 94, -77, 113, -119, -88,
52, 114, -56, -46, -18, 102, 10, 34, -127, -9, 71, 115, -70, 72, -101, 88, 72, -124, 127, 111, 74, 76, -116,
50, 111, 103, 65, 3, -77, 51, -35, 0, 119, 117, 9, -26, 119, 50, -75, -105, -102, 36, 79, 37, -68, -84,
-123, 15, -22, -109, 106, -55 };
/**
* Time to wait for coordination timeout
*/
protected final long waitForCoordMsgTimeout = 15000;
/**
* Our current view
*/
protected volatile Membership view = null;
/**
* Out current viewId
*/
protected UniqueId viewId;
/**
* Our nonblocking membership
*/
protected Membership membership = null;
/**
* indicates that we are running an election and this is the one we are running
*/
protected UniqueId suggestedviewId;
protected volatile Membership suggestedView;
protected volatile boolean started = false;
protected final int startsvc = 0xFFFF;
protected final Object electionMutex = new Object();
protected final AtomicBoolean coordMsgReceived = new AtomicBoolean(false);
public NonBlockingCoordinator() {
super();
}
// ============================================================================================================
// COORDINATION HANDLING
// ============================================================================================================
public void startElection(boolean force) throws ChannelException {
synchronized (electionMutex) {
Member local = getLocalMember(false);
Member[] others = membership.getMembers();
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_START_ELECT, this, "Election initiated"));
if (others.length == 0) {
this.viewId = new UniqueId(UUIDGenerator.randomUUID(false));
this.view = new Membership(local, AbsoluteOrder.comp, true);
this.handleViewConf(createElectionMsg(local, others, local), view);
return; // the only member, no need for an election
}
if (suggestedviewId != null) {
if (view != null && Arrays.diff(view, suggestedView, local).length == 0 &&
Arrays.diff(suggestedView, view, local).length == 0) {
suggestedviewId = null;
suggestedView = null;
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_ELECT_ABANDONED, this,
"Election abandoned, running election matches view"));
} else {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_ELECT_ABANDONED, this,
"Election abandoned, election running"));
}
return; // election already running, I'm not allowed to have two of them
}
if (view != null && Arrays.diff(view, membership, local).length == 0 &&
Arrays.diff(membership, view, local).length == 0) {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_ELECT_ABANDONED, this,
"Election abandoned, view matches membership"));
return; // already have this view installed
}
int prio = AbsoluteOrder.comp.compare(local, others[0]);
Member leader = (prio < 0) ? local : others[0];// am I the leader in my view?
if (local.equals(leader) || force) {
CoordinationMessage msg = createElectionMsg(local, others, leader);
suggestedviewId = msg.getId();
suggestedView = new Membership(local, AbsoluteOrder.comp, true);
Arrays.fill(suggestedView, msg.getMembers());
fireInterceptorEvent(
new CoordinationEvent(CoordinationEvent.EVT_PROCESS_ELECT, this, "Election, sending request"));
sendElectionMsg(local, others[0], msg);
} else {
coordMsgReceived.set(false);
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_WAIT_FOR_MSG, this,
"Election, waiting for request"));
long timeout = waitForCoordMsgTimeout;
long timeoutEndNanos = System.nanoTime() + timeout * 1_000_000;
do {
try {
electionMutex.wait(timeout);
} catch (InterruptedException x) {
Thread.currentThread().interrupt();
}
timeout = (timeoutEndNanos - System.nanoTime()) / 1_000_000;
/*
* Spurious wake-ups are possible. Keep waiting if a) the condition we were waiting for hasn't
* happened (i.e. notify() was not called) AND b) the timeout has not expired AND c) the thread was
* not interrupted.
*/
} while (suggestedviewId == null && !coordMsgReceived.get() && timeout > 0 && !Thread.interrupted());
String msg;
if (suggestedviewId == null && !coordMsgReceived.get()) {
if (Thread.interrupted()) {
msg = "Election abandoned, waiting interrupted.";
} else {
msg = "Election abandoned, waiting timed out.";
}
} else {
msg = "Election abandoned, received a message";
}
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_ELECT_ABANDONED, this, msg));
}
}
}
private CoordinationMessage createElectionMsg(Member local, Member[] others, Member leader) {
Membership m = new Membership(local, AbsoluteOrder.comp, true);
Arrays.fill(m, others);
Member[] mbrs = m.getMembers();
m.reset();
return new CoordinationMessage(leader, local, mbrs, new UniqueId(UUIDGenerator.randomUUID(true)),
COORD_REQUEST);
}
protected void sendElectionMsg(Member local, Member next, CoordinationMessage msg) throws ChannelException {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_SEND_MSG, this,
"Sending election message to(" + next.getName() + ")"));
super.sendMessage(new Member[] { next }, createData(msg, local), null);
}
protected void sendElectionMsgToNextInline(Member local, CoordinationMessage msg) throws ChannelException {
int next = Arrays.nextIndex(local, msg.getMembers());
int current = next;
msg.leader = msg.getMembers()[0];
boolean sent = false;
while (!sent && current >= 0) {
try {
sendElectionMsg(local, msg.getMembers()[current], msg);
sent = true;
} catch (ChannelException x) {
// Exception is logged further up stack
log.warn(sm.getString("nonBlockingCoordinator.electionMessage.sendfailed", msg.getMembers()[current]));
current = Arrays.nextIndex(msg.getMembers()[current], msg.getMembers());
if (current == next) {
throw x;
}
}
}
}
public ChannelData createData(CoordinationMessage msg, Member local) {
msg.write();
ChannelData data = new ChannelData(true);
data.setAddress(local);
data.setMessage(msg.getBuffer());
data.setOptions(Channel.SEND_OPTIONS_USE_ACK);
data.setTimestamp(System.currentTimeMillis());
return data;
}
protected boolean alive(Member mbr) {
return memberAlive(mbr, waitForCoordMsgTimeout);
}
protected boolean memberAlive(Member mbr, long conTimeout) {
// could be a shutdown notification
if (Arrays.equals(mbr.getCommand(), Member.SHUTDOWN_PAYLOAD)) {
return false;
}
try (Socket socket = new Socket()) {
InetAddress ia = InetAddress.getByAddress(mbr.getHost());
InetSocketAddress addr = new InetSocketAddress(ia, mbr.getPort());
socket.connect(addr, (int) conTimeout);
return true;
} catch (SocketTimeoutException | ConnectException x) {
// do nothing, we couldn't connect
} catch (Exception e) {
log.error(sm.getString("nonBlockingCoordinator.memberAlive.failed"), e);
}
return false;
}
protected Membership mergeOnArrive(CoordinationMessage msg) {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_PRE_MERGE, this, "Pre merge"));
Member local = getLocalMember(false);
Membership merged = new Membership(local, AbsoluteOrder.comp, true);
Arrays.fill(merged, msg.getMembers());
Arrays.fill(merged, getMembers());
Member[] diff = Arrays.diff(merged, membership, local);
for (Member member : diff) {
if (!alive(member)) {
merged.removeMember(member);
} else {
memberAdded(member, false);
}
}
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_POST_MERGE, this, "Post merge"));
return merged;
}
protected void processCoordMessage(CoordinationMessage msg) throws ChannelException {
if (!coordMsgReceived.get()) {
coordMsgReceived.set(true);
synchronized (electionMutex) {
electionMutex.notifyAll();
}
}
Membership merged = mergeOnArrive(msg);
if (isViewConf(msg)) {
handleViewConf(msg, merged);
} else {
handleToken(msg, merged);
}
}
protected void handleToken(CoordinationMessage msg, Membership merged) throws ChannelException {
Member local = getLocalMember(false);
if (local.equals(msg.getSource())) {
// my message msg.src=local
handleMyToken(local, msg, merged);
} else {
handleOtherToken(local, msg, merged);
}
}
protected void handleMyToken(Member local, CoordinationMessage msg, Membership merged) throws ChannelException {
if (local.equals(msg.getLeader())) {
// no leadership change
if (Arrays.sameMembers(msg.getMembers(), merged.getMembers())) {
msg.type = COORD_CONF;
super.sendMessage(Arrays.remove(msg.getMembers(), local), createData(msg, local), null);
handleViewConf(msg, merged);
} else {
// membership change
suggestedView = new Membership(local, AbsoluteOrder.comp, true);
suggestedviewId = msg.getId();
Arrays.fill(suggestedView, merged.getMembers());
msg.view = merged.getMembers();
sendElectionMsgToNextInline(local, msg);
}
} else {
// leadership change
suggestedView = null;
suggestedviewId = null;
msg.view = merged.getMembers();
sendElectionMsgToNextInline(local, msg);
}
}
protected void handleOtherToken(Member local, CoordinationMessage msg, Membership merged) throws ChannelException {
if (local.equals(msg.getLeader())) {
// I am the new leader
// startElection(false);
} else {
msg.view = merged.getMembers();
sendElectionMsgToNextInline(local, msg);
}
}
protected void handleViewConf(CoordinationMessage msg, Membership merged) throws ChannelException {
if (viewId != null && msg.getId().equals(viewId)) {
return;// we already have this view
}
view = new Membership(getLocalMember(false), AbsoluteOrder.comp, true);
Arrays.fill(view, msg.getMembers());
viewId = msg.getId();
if (viewId.equals(suggestedviewId)) {
suggestedView = null;
suggestedviewId = null;
}
if (suggestedView != null &&
AbsoluteOrder.comp.compare(suggestedView.getMembers()[0], merged.getMembers()[0]) < 0) {
suggestedView = null;
suggestedviewId = null;
}
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_CONF_RX, this, "Accepted View"));
if (suggestedviewId == null && hasHigherPriority(merged.getMembers(), membership.getMembers())) {
startElection(false);
}
}
protected boolean isViewConf(CoordinationMessage msg) {
return Arrays.contains(msg.getType(), 0, COORD_CONF, 0, COORD_CONF.length);
}
protected boolean hasHigherPriority(Member[] complete, Member[] local) {
if (local == null || local.length == 0) {
return false;
}
if (complete == null || complete.length == 0) {
return true;
}
AbsoluteOrder.absoluteOrder(complete);
AbsoluteOrder.absoluteOrder(local);
return (AbsoluteOrder.comp.compare(complete[0], local[0]) > 0);
}
/**
* Returns coordinator if one is available
*
* @return Member
*/
public Member getCoordinator() {
return (view != null && view.hasMembers()) ? view.getMembers()[0] : null;
}
public Member[] getView() {
return (view != null && view.hasMembers()) ? view.getMembers() : new Member[0];
}
public UniqueId getViewId() {
return viewId;
}
/**
* Block in/out messages while an election is going on
*/
protected void halt() {
}
/**
* Release lock for in/out messages election is completed
*/
protected void release() {
}
/**
* Wait for an election to end
*/
protected void waitForRelease() {
}
// ============================================================================================================
// OVERRIDDEN METHODS FROM CHANNEL INTERCEPTOR BASE
// ============================================================================================================
@Override
public void start(int svc) throws ChannelException {
if (membership == null) {
setupMembership();
}
if (started) {
return;
}
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_START, this, "Before start"));
super.start(startsvc);
started = true;
if (view == null) {
view = new Membership(super.getLocalMember(true), AbsoluteOrder.comp, true);
}
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_START, this, "After start"));
startElection(false);
}
@Override
public void stop(int svc) throws ChannelException {
try {
halt();
synchronized (electionMutex) {
if (!started) {
return;
}
started = false;
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_STOP, this, "Before stop"));
super.stop(startsvc);
this.view = null;
this.viewId = null;
this.suggestedView = null;
this.suggestedviewId = null;
this.membership.reset();
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_STOP, this, "After stop"));
}
} finally {
release();
}
}
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
throws ChannelException {
waitForRelease();
super.sendMessage(destination, msg, payload);
}
@Override
public void messageReceived(ChannelMessage msg) {
if (Arrays.contains(msg.getMessage().getBytesDirect(), 0, COORD_ALIVE, 0, COORD_ALIVE.length)) {
// ignore message, it's an alive message
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE, this, "Alive Message"));
} else if (Arrays.contains(msg.getMessage().getBytesDirect(), 0, COORD_HEADER, 0, COORD_HEADER.length)) {
try {
CoordinationMessage cmsg = new CoordinationMessage(msg.getMessage());
Member[] cmbr = cmsg.getMembers();
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE, this,
"Coord Msg Arrived(" + Arrays.toNameString(cmbr) + ")"));
processCoordMessage(cmsg);
} catch (ChannelException x) {
log.error(sm.getString("nonBlockingCoordinator.processCoordinationMessage.failed"), x);
}
} else {
super.messageReceived(msg);
}
}
@Override
public void memberAdded(Member member) {
memberAdded(member, true);
}
public void memberAdded(Member member, boolean elect) {
if (membership == null) {
setupMembership();
}
if (membership.memberAlive(member)) {
super.memberAdded(member);
}
try {
fireInterceptorEvent(
new CoordinationEvent(CoordinationEvent.EVT_MBR_ADD, this, "Member add(" + member.getName() + ")"));
if (started && elect) {
startElection(false);
}
} catch (ChannelException x) {
log.error(sm.getString("nonBlockingCoordinator.memberAdded.failed"), x);
}
}
@Override
public void memberDisappeared(Member member) {
membership.removeMember(member);
super.memberDisappeared(member);
try {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MBR_DEL, this,
"Member remove(" + member.getName() + ")"));
if (started && (isCoordinator() || isHighest())) {
startElection(true); // to do, if a member disappears, only the coordinator can start
}
} catch (ChannelException x) {
log.error(sm.getString("nonBlockingCoordinator.memberDisappeared.failed"), x);
}
}
public boolean isHighest() {
Member local = getLocalMember(false);
if (membership.getMembers().length == 0) {
return true;
} else {
return AbsoluteOrder.comp.compare(local, membership.getMembers()[0]) <= 0;
}
}
public boolean isCoordinator() {
Member coord = getCoordinator();
return coord != null && getLocalMember(false).equals(coord);
}
@Override
public void heartbeat() {
try {
Member local = getLocalMember(false);
if (view != null && (Arrays.diff(view, membership, local).length != 0 ||
Arrays.diff(membership, view, local).length != 0)) {
if (isHighest()) {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_START_ELECT, this,
sm.getString("nonBlockingCoordinator.heartbeat.inconsistency")));
startElection(true);
}
}
} catch (Exception e) {
log.error(sm.getString("nonBlockingCoordinator.heartbeat.failed"), e);
} finally {
super.heartbeat();
}
}
@Override
public boolean hasMembers() {
return membership.hasMembers();
}
@Override
public Member[] getMembers() {
return membership.getMembers();
}
@Override
public Member getMember(Member mbr) {
return membership.getMember(mbr);
}
@Override
public Member getLocalMember(boolean incAlive) {
Member local = super.getLocalMember(incAlive);
if (view == null && (local != null)) {
setupMembership();
}
return local;
}
protected synchronized void setupMembership() {
if (membership == null) {
membership = new Membership(super.getLocalMember(true), AbsoluteOrder.comp, false);
}
}
// ============================================================================================================
// HELPER CLASSES FOR COORDINATION
// ============================================================================================================
public static class CoordinationMessage {
// X{A-ldr, A-src, mbrs-A,B,C,D}
protected final XByteBuffer buf;
protected Member leader;
protected Member source;
protected Member[] view;
protected UniqueId id;
protected byte[] type;
public CoordinationMessage(XByteBuffer buf) {
this.buf = buf;
parse();
}
public CoordinationMessage(Member leader, Member source, Member[] view, UniqueId id, byte[] type) {
this.buf = new XByteBuffer(4096, false);
this.leader = leader;
this.source = source;
this.view = view;
this.id = id;
this.type = type;
this.write();
}
public byte[] getHeader() {
return COORD_HEADER;
}
public Member getLeader() {
if (leader == null) {
parse();
}
return leader;
}
public Member getSource() {
if (source == null) {
parse();
}
return source;
}
public UniqueId getId() {
if (id == null) {
parse();
}
return id;
}
public Member[] getMembers() {
if (view == null) {
parse();
}
return view;
}
public byte[] getType() {
if (type == null) {
parse();
}
return type;
}
public XByteBuffer getBuffer() {
return this.buf;
}
public void parse() {
// header
int offset = 16;
// leader
int ldrLen = XByteBuffer.toInt(buf.getBytesDirect(), offset);
offset += 4;
byte[] ldr = new byte[ldrLen];
System.arraycopy(buf.getBytesDirect(), offset, ldr, 0, ldrLen);
leader = MemberImpl.getMember(ldr);
offset += ldrLen;
// source
int srcLen = XByteBuffer.toInt(buf.getBytesDirect(), offset);
offset += 4;
byte[] src = new byte[srcLen];
System.arraycopy(buf.getBytesDirect(), offset, src, 0, srcLen);
source = MemberImpl.getMember(src);
offset += srcLen;
// view
int mbrCount = XByteBuffer.toInt(buf.getBytesDirect(), offset);
offset += 4;
view = new Member[mbrCount];
for (int i = 0; i < view.length; i++) {
int mbrLen = XByteBuffer.toInt(buf.getBytesDirect(), offset);
offset += 4;
byte[] mbr = new byte[mbrLen];
System.arraycopy(buf.getBytesDirect(), offset, mbr, 0, mbrLen);
view[i] = MemberImpl.getMember(mbr);
offset += mbrLen;
}
// id
this.id = new UniqueId(buf.getBytesDirect(), offset, 16);
offset += 16;
type = new byte[16];
System.arraycopy(buf.getBytesDirect(), offset, type, 0, type.length);
offset += 16;
}
public void write() {
buf.reset();
// header
buf.append(COORD_HEADER, 0, COORD_HEADER.length);
// leader
byte[] ldr = leader.getData(false, false);
buf.append(ldr.length);
buf.append(ldr, 0, ldr.length);
// source
byte[] src = source.getData(false, false);
buf.append(src.length);
buf.append(src, 0, src.length);
// view
buf.append(view.length);
for (Member member : view) {
byte[] mbr = member.getData(false, false);
buf.append(mbr.length);
buf.append(mbr, 0, mbr.length);
}
// id
buf.append(id.getBytes(), 0, id.getBytes().length);
buf.append(type, 0, type.length);
}
}
@Override
public void fireInterceptorEvent(InterceptorEvent event) {
if (event instanceof CoordinationEvent) {
if (((CoordinationEvent) event).type == CoordinationEvent.EVT_CONF_RX) {
log.info(event);
} else {
if (log.isDebugEnabled()) {
log.debug(event);
}
}
}
}
public static class CoordinationEvent implements InterceptorEvent {
public static final int EVT_START = 1;
public static final int EVT_MBR_ADD = 2;
public static final int EVT_MBR_DEL = 3;
public static final int EVT_START_ELECT = 4;
public static final int EVT_PROCESS_ELECT = 5;
public static final int EVT_MSG_ARRIVE = 6;
public static final int EVT_PRE_MERGE = 7;
public static final int EVT_POST_MERGE = 8;
public static final int EVT_WAIT_FOR_MSG = 9;
public static final int EVT_SEND_MSG = 10;
public static final int EVT_STOP = 11;
public static final int EVT_CONF_RX = 12;
public static final int EVT_ELECT_ABANDONED = 13;
final int type;
final ChannelInterceptor interceptor;
final Member coord;
final Member[] mbrs;
final String info;
final Membership view;
final Membership suggestedView;
public CoordinationEvent(int type, ChannelInterceptor interceptor, String info) {
this.type = type;
this.interceptor = interceptor;
this.coord = ((NonBlockingCoordinator) interceptor).getCoordinator();
this.mbrs = ((NonBlockingCoordinator) interceptor).membership.getMembers();
this.info = info;
this.view = ((NonBlockingCoordinator) interceptor).view;
this.suggestedView = ((NonBlockingCoordinator) interceptor).suggestedView;
}
@Override
public int getEventType() {
return type;
}
@Override
public String getEventTypeDesc() {
return switch (type) {
case EVT_START -> "EVT_START:" + info;
case EVT_MBR_ADD -> "EVT_MBR_ADD:" + info;
case EVT_MBR_DEL -> "EVT_MBR_DEL:" + info;
case EVT_START_ELECT -> "EVT_START_ELECT:" + info;
case EVT_PROCESS_ELECT -> "EVT_PROCESS_ELECT:" + info;
case EVT_MSG_ARRIVE -> "EVT_MSG_ARRIVE:" + info;
case EVT_PRE_MERGE -> "EVT_PRE_MERGE:" + info;
case EVT_POST_MERGE -> "EVT_POST_MERGE:" + info;
case EVT_WAIT_FOR_MSG -> "EVT_WAIT_FOR_MSG:" + info;
case EVT_SEND_MSG -> "EVT_SEND_MSG:" + info;
case EVT_STOP -> "EVT_STOP:" + info;
case EVT_CONF_RX -> "EVT_CONF_RX:" + info;
case EVT_ELECT_ABANDONED -> "EVT_ELECT_ABANDONED:" + info;
default -> "Unknown";
};
}
@Override
public ChannelInterceptor getInterceptor() {
return interceptor;
}
@Override
public String toString() {
Member local = interceptor.getLocalMember(false);
return sm.getString("nonBlockingCoordinator.report", Integer.valueOf(type),
(local != null ? local.getName() : ""), (coord != null ? coord.getName() : ""),
Arrays.toNameString(view != null ? view.getMembers() : null),
Arrays.toNameString(suggestedView != null ? suggestedView.getMembers() : null),
Arrays.toNameString(mbrs), info);
}
}
}
|
googleapis/google-cloud-java | 36,668 | java-compute/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/RegionInstanceGroupManagersSettings.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.compute.v1;
import static com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListErrorsPagedResponse;
import static com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListManagedInstancesPagedResponse;
import static com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListPagedResponse;
import static com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListPerInstanceConfigsPagedResponse;
import com.google.api.core.ApiFunction;
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.OperationCallSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.compute.v1.stub.RegionInstanceGroupManagersStubSettings;
import java.io.IOException;
import java.util.List;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Settings class to configure an instance of {@link RegionInstanceGroupManagersClient}.
*
* <p>The default instance has everything set to sensible defaults:
*
* <ul>
* <li>The default service address (compute.googleapis.com) and default port (443) are used.
* <li>Credentials are acquired automatically through Application Default Credentials.
* <li>Retries are configured for idempotent methods but not for non-idempotent methods.
* </ul>
*
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of get:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* RegionInstanceGroupManagersSettings.Builder regionInstanceGroupManagersSettingsBuilder =
* RegionInstanceGroupManagersSettings.newBuilder();
* regionInstanceGroupManagersSettingsBuilder
* .getSettings()
* .setRetrySettings(
* regionInstanceGroupManagersSettingsBuilder
* .getSettings()
* .getRetrySettings()
* .toBuilder()
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* RegionInstanceGroupManagersSettings regionInstanceGroupManagersSettings =
* regionInstanceGroupManagersSettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*
* <p>To configure the RetrySettings of a Long Running Operation method, create an
* OperationTimedPollAlgorithm object and update the RPC's polling algorithm. For example, to
* configure the RetrySettings for abandonInstances:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* RegionInstanceGroupManagersSettings.Builder regionInstanceGroupManagersSettingsBuilder =
* RegionInstanceGroupManagersSettings.newBuilder();
* TimedRetryAlgorithm timedRetryAlgorithm =
* OperationalTimedPollAlgorithm.create(
* RetrySettings.newBuilder()
* .setInitialRetryDelayDuration(Duration.ofMillis(500))
* .setRetryDelayMultiplier(1.5)
* .setMaxRetryDelayDuration(Duration.ofMillis(5000))
* .setTotalTimeoutDuration(Duration.ofHours(24))
* .build());
* regionInstanceGroupManagersSettingsBuilder
* .createClusterOperationSettings()
* .setPollingAlgorithm(timedRetryAlgorithm)
* .build();
* }</pre>
*/
@Generated("by gapic-generator-java")
public class RegionInstanceGroupManagersSettings
extends ClientSettings<RegionInstanceGroupManagersSettings> {
/** Returns the object with the settings used for calls to abandonInstances. */
public UnaryCallSettings<AbandonInstancesRegionInstanceGroupManagerRequest, Operation>
abandonInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).abandonInstancesSettings();
}
/** Returns the object with the settings used for calls to abandonInstances. */
public OperationCallSettings<
AbandonInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
abandonInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.abandonInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to applyUpdatesToInstances. */
public UnaryCallSettings<ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, Operation>
applyUpdatesToInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.applyUpdatesToInstancesSettings();
}
/** Returns the object with the settings used for calls to applyUpdatesToInstances. */
public OperationCallSettings<
ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
applyUpdatesToInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.applyUpdatesToInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to createInstances. */
public UnaryCallSettings<CreateInstancesRegionInstanceGroupManagerRequest, Operation>
createInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).createInstancesSettings();
}
/** Returns the object with the settings used for calls to createInstances. */
public OperationCallSettings<
CreateInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
createInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.createInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to delete. */
public UnaryCallSettings<DeleteRegionInstanceGroupManagerRequest, Operation> deleteSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).deleteSettings();
}
/** Returns the object with the settings used for calls to delete. */
public OperationCallSettings<DeleteRegionInstanceGroupManagerRequest, Operation, Operation>
deleteOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).deleteOperationSettings();
}
/** Returns the object with the settings used for calls to deleteInstances. */
public UnaryCallSettings<DeleteInstancesRegionInstanceGroupManagerRequest, Operation>
deleteInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).deleteInstancesSettings();
}
/** Returns the object with the settings used for calls to deleteInstances. */
public OperationCallSettings<
DeleteInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
deleteInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.deleteInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to deletePerInstanceConfigs. */
public UnaryCallSettings<DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation>
deletePerInstanceConfigsSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.deletePerInstanceConfigsSettings();
}
/** Returns the object with the settings used for calls to deletePerInstanceConfigs. */
public OperationCallSettings<
DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation, Operation>
deletePerInstanceConfigsOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.deletePerInstanceConfigsOperationSettings();
}
/** Returns the object with the settings used for calls to get. */
public UnaryCallSettings<GetRegionInstanceGroupManagerRequest, InstanceGroupManager>
getSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).getSettings();
}
/** Returns the object with the settings used for calls to insert. */
public UnaryCallSettings<InsertRegionInstanceGroupManagerRequest, Operation> insertSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).insertSettings();
}
/** Returns the object with the settings used for calls to insert. */
public OperationCallSettings<InsertRegionInstanceGroupManagerRequest, Operation, Operation>
insertOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).insertOperationSettings();
}
/** Returns the object with the settings used for calls to list. */
public PagedCallSettings<
ListRegionInstanceGroupManagersRequest, RegionInstanceGroupManagerList, ListPagedResponse>
listSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).listSettings();
}
/** Returns the object with the settings used for calls to listErrors. */
public PagedCallSettings<
ListErrorsRegionInstanceGroupManagersRequest,
RegionInstanceGroupManagersListErrorsResponse,
ListErrorsPagedResponse>
listErrorsSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).listErrorsSettings();
}
/** Returns the object with the settings used for calls to listManagedInstances. */
public PagedCallSettings<
ListManagedInstancesRegionInstanceGroupManagersRequest,
RegionInstanceGroupManagersListInstancesResponse,
ListManagedInstancesPagedResponse>
listManagedInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.listManagedInstancesSettings();
}
/** Returns the object with the settings used for calls to listPerInstanceConfigs. */
public PagedCallSettings<
ListPerInstanceConfigsRegionInstanceGroupManagersRequest,
RegionInstanceGroupManagersListInstanceConfigsResp,
ListPerInstanceConfigsPagedResponse>
listPerInstanceConfigsSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.listPerInstanceConfigsSettings();
}
/** Returns the object with the settings used for calls to patch. */
public UnaryCallSettings<PatchRegionInstanceGroupManagerRequest, Operation> patchSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).patchSettings();
}
/** Returns the object with the settings used for calls to patch. */
public OperationCallSettings<PatchRegionInstanceGroupManagerRequest, Operation, Operation>
patchOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).patchOperationSettings();
}
/** Returns the object with the settings used for calls to patchPerInstanceConfigs. */
public UnaryCallSettings<PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, Operation>
patchPerInstanceConfigsSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.patchPerInstanceConfigsSettings();
}
/** Returns the object with the settings used for calls to patchPerInstanceConfigs. */
public OperationCallSettings<
PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, Operation, Operation>
patchPerInstanceConfigsOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.patchPerInstanceConfigsOperationSettings();
}
/** Returns the object with the settings used for calls to recreateInstances. */
public UnaryCallSettings<RecreateInstancesRegionInstanceGroupManagerRequest, Operation>
recreateInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.recreateInstancesSettings();
}
/** Returns the object with the settings used for calls to recreateInstances. */
public OperationCallSettings<
RecreateInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
recreateInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.recreateInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to resize. */
public UnaryCallSettings<ResizeRegionInstanceGroupManagerRequest, Operation> resizeSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).resizeSettings();
}
/** Returns the object with the settings used for calls to resize. */
public OperationCallSettings<ResizeRegionInstanceGroupManagerRequest, Operation, Operation>
resizeOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).resizeOperationSettings();
}
/** Returns the object with the settings used for calls to resumeInstances. */
public UnaryCallSettings<ResumeInstancesRegionInstanceGroupManagerRequest, Operation>
resumeInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).resumeInstancesSettings();
}
/** Returns the object with the settings used for calls to resumeInstances. */
public OperationCallSettings<
ResumeInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
resumeInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.resumeInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to setInstanceTemplate. */
public UnaryCallSettings<SetInstanceTemplateRegionInstanceGroupManagerRequest, Operation>
setInstanceTemplateSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.setInstanceTemplateSettings();
}
/** Returns the object with the settings used for calls to setInstanceTemplate. */
public OperationCallSettings<
SetInstanceTemplateRegionInstanceGroupManagerRequest, Operation, Operation>
setInstanceTemplateOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.setInstanceTemplateOperationSettings();
}
/** Returns the object with the settings used for calls to setTargetPools. */
public UnaryCallSettings<SetTargetPoolsRegionInstanceGroupManagerRequest, Operation>
setTargetPoolsSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).setTargetPoolsSettings();
}
/** Returns the object with the settings used for calls to setTargetPools. */
public OperationCallSettings<
SetTargetPoolsRegionInstanceGroupManagerRequest, Operation, Operation>
setTargetPoolsOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.setTargetPoolsOperationSettings();
}
/** Returns the object with the settings used for calls to startInstances. */
public UnaryCallSettings<StartInstancesRegionInstanceGroupManagerRequest, Operation>
startInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).startInstancesSettings();
}
/** Returns the object with the settings used for calls to startInstances. */
public OperationCallSettings<
StartInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
startInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.startInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to stopInstances. */
public UnaryCallSettings<StopInstancesRegionInstanceGroupManagerRequest, Operation>
stopInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).stopInstancesSettings();
}
/** Returns the object with the settings used for calls to stopInstances. */
public OperationCallSettings<StopInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
stopInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.stopInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to suspendInstances. */
public UnaryCallSettings<SuspendInstancesRegionInstanceGroupManagerRequest, Operation>
suspendInstancesSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings()).suspendInstancesSettings();
}
/** Returns the object with the settings used for calls to suspendInstances. */
public OperationCallSettings<
SuspendInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
suspendInstancesOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.suspendInstancesOperationSettings();
}
/** Returns the object with the settings used for calls to updatePerInstanceConfigs. */
public UnaryCallSettings<UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation>
updatePerInstanceConfigsSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.updatePerInstanceConfigsSettings();
}
/** Returns the object with the settings used for calls to updatePerInstanceConfigs. */
public OperationCallSettings<
UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation, Operation>
updatePerInstanceConfigsOperationSettings() {
return ((RegionInstanceGroupManagersStubSettings) getStubSettings())
.updatePerInstanceConfigsOperationSettings();
}
public static final RegionInstanceGroupManagersSettings create(
RegionInstanceGroupManagersStubSettings stub) throws IOException {
return new RegionInstanceGroupManagersSettings.Builder(stub.toBuilder()).build();
}
/** Returns a builder for the default ExecutorProvider for this service. */
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
return RegionInstanceGroupManagersStubSettings.defaultExecutorProviderBuilder();
}
/** Returns the default service endpoint. */
public static String getDefaultEndpoint() {
return RegionInstanceGroupManagersStubSettings.getDefaultEndpoint();
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return RegionInstanceGroupManagersStubSettings.getDefaultServiceScopes();
}
/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return RegionInstanceGroupManagersStubSettings.defaultCredentialsProviderBuilder();
}
/** Returns a builder for the default ChannelProvider for this service. */
public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder() {
return RegionInstanceGroupManagersStubSettings.defaultHttpJsonTransportProviderBuilder();
}
public static TransportChannelProvider defaultTransportChannelProvider() {
return RegionInstanceGroupManagersStubSettings.defaultTransportChannelProvider();
}
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
return RegionInstanceGroupManagersStubSettings.defaultApiClientHeaderProviderBuilder();
}
/** Returns a new builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
}
/** Returns a builder containing all the values of this settings class. */
public Builder toBuilder() {
return new Builder(this);
}
protected RegionInstanceGroupManagersSettings(Builder settingsBuilder) throws IOException {
super(settingsBuilder);
}
/** Builder for RegionInstanceGroupManagersSettings. */
public static class Builder
extends ClientSettings.Builder<RegionInstanceGroupManagersSettings, Builder> {
protected Builder() throws IOException {
this(((ClientContext) null));
}
protected Builder(ClientContext clientContext) {
super(RegionInstanceGroupManagersStubSettings.newBuilder(clientContext));
}
protected Builder(RegionInstanceGroupManagersSettings settings) {
super(settings.getStubSettings().toBuilder());
}
protected Builder(RegionInstanceGroupManagersStubSettings.Builder stubSettings) {
super(stubSettings);
}
private static Builder createDefault() {
return new Builder(RegionInstanceGroupManagersStubSettings.newBuilder());
}
public RegionInstanceGroupManagersStubSettings.Builder getStubSettingsBuilder() {
return ((RegionInstanceGroupManagersStubSettings.Builder) getStubSettings());
}
/**
* Applies the given settings updater function to all of the unary API methods in this service.
*
* <p>Note: This method does not support applying settings to streaming methods.
*/
public Builder applyToAllUnaryMethods(
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
super.applyToAllUnaryMethods(
getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
return this;
}
/** Returns the builder for the settings used for calls to abandonInstances. */
public UnaryCallSettings.Builder<AbandonInstancesRegionInstanceGroupManagerRequest, Operation>
abandonInstancesSettings() {
return getStubSettingsBuilder().abandonInstancesSettings();
}
/** Returns the builder for the settings used for calls to abandonInstances. */
public OperationCallSettings.Builder<
AbandonInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
abandonInstancesOperationSettings() {
return getStubSettingsBuilder().abandonInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to applyUpdatesToInstances. */
public UnaryCallSettings.Builder<
ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, Operation>
applyUpdatesToInstancesSettings() {
return getStubSettingsBuilder().applyUpdatesToInstancesSettings();
}
/** Returns the builder for the settings used for calls to applyUpdatesToInstances. */
public OperationCallSettings.Builder<
ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
applyUpdatesToInstancesOperationSettings() {
return getStubSettingsBuilder().applyUpdatesToInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to createInstances. */
public UnaryCallSettings.Builder<CreateInstancesRegionInstanceGroupManagerRequest, Operation>
createInstancesSettings() {
return getStubSettingsBuilder().createInstancesSettings();
}
/** Returns the builder for the settings used for calls to createInstances. */
public OperationCallSettings.Builder<
CreateInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
createInstancesOperationSettings() {
return getStubSettingsBuilder().createInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to delete. */
public UnaryCallSettings.Builder<DeleteRegionInstanceGroupManagerRequest, Operation>
deleteSettings() {
return getStubSettingsBuilder().deleteSettings();
}
/** Returns the builder for the settings used for calls to delete. */
public OperationCallSettings.Builder<
DeleteRegionInstanceGroupManagerRequest, Operation, Operation>
deleteOperationSettings() {
return getStubSettingsBuilder().deleteOperationSettings();
}
/** Returns the builder for the settings used for calls to deleteInstances. */
public UnaryCallSettings.Builder<DeleteInstancesRegionInstanceGroupManagerRequest, Operation>
deleteInstancesSettings() {
return getStubSettingsBuilder().deleteInstancesSettings();
}
/** Returns the builder for the settings used for calls to deleteInstances. */
public OperationCallSettings.Builder<
DeleteInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
deleteInstancesOperationSettings() {
return getStubSettingsBuilder().deleteInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to deletePerInstanceConfigs. */
public UnaryCallSettings.Builder<
DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation>
deletePerInstanceConfigsSettings() {
return getStubSettingsBuilder().deletePerInstanceConfigsSettings();
}
/** Returns the builder for the settings used for calls to deletePerInstanceConfigs. */
public OperationCallSettings.Builder<
DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation, Operation>
deletePerInstanceConfigsOperationSettings() {
return getStubSettingsBuilder().deletePerInstanceConfigsOperationSettings();
}
/** Returns the builder for the settings used for calls to get. */
public UnaryCallSettings.Builder<GetRegionInstanceGroupManagerRequest, InstanceGroupManager>
getSettings() {
return getStubSettingsBuilder().getSettings();
}
/** Returns the builder for the settings used for calls to insert. */
public UnaryCallSettings.Builder<InsertRegionInstanceGroupManagerRequest, Operation>
insertSettings() {
return getStubSettingsBuilder().insertSettings();
}
/** Returns the builder for the settings used for calls to insert. */
public OperationCallSettings.Builder<
InsertRegionInstanceGroupManagerRequest, Operation, Operation>
insertOperationSettings() {
return getStubSettingsBuilder().insertOperationSettings();
}
/** Returns the builder for the settings used for calls to list. */
public PagedCallSettings.Builder<
ListRegionInstanceGroupManagersRequest,
RegionInstanceGroupManagerList,
ListPagedResponse>
listSettings() {
return getStubSettingsBuilder().listSettings();
}
/** Returns the builder for the settings used for calls to listErrors. */
public PagedCallSettings.Builder<
ListErrorsRegionInstanceGroupManagersRequest,
RegionInstanceGroupManagersListErrorsResponse,
ListErrorsPagedResponse>
listErrorsSettings() {
return getStubSettingsBuilder().listErrorsSettings();
}
/** Returns the builder for the settings used for calls to listManagedInstances. */
public PagedCallSettings.Builder<
ListManagedInstancesRegionInstanceGroupManagersRequest,
RegionInstanceGroupManagersListInstancesResponse,
ListManagedInstancesPagedResponse>
listManagedInstancesSettings() {
return getStubSettingsBuilder().listManagedInstancesSettings();
}
/** Returns the builder for the settings used for calls to listPerInstanceConfigs. */
public PagedCallSettings.Builder<
ListPerInstanceConfigsRegionInstanceGroupManagersRequest,
RegionInstanceGroupManagersListInstanceConfigsResp,
ListPerInstanceConfigsPagedResponse>
listPerInstanceConfigsSettings() {
return getStubSettingsBuilder().listPerInstanceConfigsSettings();
}
/** Returns the builder for the settings used for calls to patch. */
public UnaryCallSettings.Builder<PatchRegionInstanceGroupManagerRequest, Operation>
patchSettings() {
return getStubSettingsBuilder().patchSettings();
}
/** Returns the builder for the settings used for calls to patch. */
public OperationCallSettings.Builder<
PatchRegionInstanceGroupManagerRequest, Operation, Operation>
patchOperationSettings() {
return getStubSettingsBuilder().patchOperationSettings();
}
/** Returns the builder for the settings used for calls to patchPerInstanceConfigs. */
public UnaryCallSettings.Builder<
PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, Operation>
patchPerInstanceConfigsSettings() {
return getStubSettingsBuilder().patchPerInstanceConfigsSettings();
}
/** Returns the builder for the settings used for calls to patchPerInstanceConfigs. */
public OperationCallSettings.Builder<
PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, Operation, Operation>
patchPerInstanceConfigsOperationSettings() {
return getStubSettingsBuilder().patchPerInstanceConfigsOperationSettings();
}
/** Returns the builder for the settings used for calls to recreateInstances. */
public UnaryCallSettings.Builder<RecreateInstancesRegionInstanceGroupManagerRequest, Operation>
recreateInstancesSettings() {
return getStubSettingsBuilder().recreateInstancesSettings();
}
/** Returns the builder for the settings used for calls to recreateInstances. */
public OperationCallSettings.Builder<
RecreateInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
recreateInstancesOperationSettings() {
return getStubSettingsBuilder().recreateInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to resize. */
public UnaryCallSettings.Builder<ResizeRegionInstanceGroupManagerRequest, Operation>
resizeSettings() {
return getStubSettingsBuilder().resizeSettings();
}
/** Returns the builder for the settings used for calls to resize. */
public OperationCallSettings.Builder<
ResizeRegionInstanceGroupManagerRequest, Operation, Operation>
resizeOperationSettings() {
return getStubSettingsBuilder().resizeOperationSettings();
}
/** Returns the builder for the settings used for calls to resumeInstances. */
public UnaryCallSettings.Builder<ResumeInstancesRegionInstanceGroupManagerRequest, Operation>
resumeInstancesSettings() {
return getStubSettingsBuilder().resumeInstancesSettings();
}
/** Returns the builder for the settings used for calls to resumeInstances. */
public OperationCallSettings.Builder<
ResumeInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
resumeInstancesOperationSettings() {
return getStubSettingsBuilder().resumeInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to setInstanceTemplate. */
public UnaryCallSettings.Builder<
SetInstanceTemplateRegionInstanceGroupManagerRequest, Operation>
setInstanceTemplateSettings() {
return getStubSettingsBuilder().setInstanceTemplateSettings();
}
/** Returns the builder for the settings used for calls to setInstanceTemplate. */
public OperationCallSettings.Builder<
SetInstanceTemplateRegionInstanceGroupManagerRequest, Operation, Operation>
setInstanceTemplateOperationSettings() {
return getStubSettingsBuilder().setInstanceTemplateOperationSettings();
}
/** Returns the builder for the settings used for calls to setTargetPools. */
public UnaryCallSettings.Builder<SetTargetPoolsRegionInstanceGroupManagerRequest, Operation>
setTargetPoolsSettings() {
return getStubSettingsBuilder().setTargetPoolsSettings();
}
/** Returns the builder for the settings used for calls to setTargetPools. */
public OperationCallSettings.Builder<
SetTargetPoolsRegionInstanceGroupManagerRequest, Operation, Operation>
setTargetPoolsOperationSettings() {
return getStubSettingsBuilder().setTargetPoolsOperationSettings();
}
/** Returns the builder for the settings used for calls to startInstances. */
public UnaryCallSettings.Builder<StartInstancesRegionInstanceGroupManagerRequest, Operation>
startInstancesSettings() {
return getStubSettingsBuilder().startInstancesSettings();
}
/** Returns the builder for the settings used for calls to startInstances. */
public OperationCallSettings.Builder<
StartInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
startInstancesOperationSettings() {
return getStubSettingsBuilder().startInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to stopInstances. */
public UnaryCallSettings.Builder<StopInstancesRegionInstanceGroupManagerRequest, Operation>
stopInstancesSettings() {
return getStubSettingsBuilder().stopInstancesSettings();
}
/** Returns the builder for the settings used for calls to stopInstances. */
public OperationCallSettings.Builder<
StopInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
stopInstancesOperationSettings() {
return getStubSettingsBuilder().stopInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to suspendInstances. */
public UnaryCallSettings.Builder<SuspendInstancesRegionInstanceGroupManagerRequest, Operation>
suspendInstancesSettings() {
return getStubSettingsBuilder().suspendInstancesSettings();
}
/** Returns the builder for the settings used for calls to suspendInstances. */
public OperationCallSettings.Builder<
SuspendInstancesRegionInstanceGroupManagerRequest, Operation, Operation>
suspendInstancesOperationSettings() {
return getStubSettingsBuilder().suspendInstancesOperationSettings();
}
/** Returns the builder for the settings used for calls to updatePerInstanceConfigs. */
public UnaryCallSettings.Builder<
UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation>
updatePerInstanceConfigsSettings() {
return getStubSettingsBuilder().updatePerInstanceConfigsSettings();
}
/** Returns the builder for the settings used for calls to updatePerInstanceConfigs. */
public OperationCallSettings.Builder<
UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, Operation, Operation>
updatePerInstanceConfigsOperationSettings() {
return getStubSettingsBuilder().updatePerInstanceConfigsOperationSettings();
}
@Override
public RegionInstanceGroupManagersSettings build() throws IOException {
return new RegionInstanceGroupManagersSettings(this);
}
}
}
|
googleapis/google-api-java-client-services | 36,414 | clients/google-api-services-drive/v3/1.26.0/com/google/api/services/drive/model/Drive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Representation of a shared drive.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Drive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this shared drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdTime;
/**
* Whether the shared drive is hidden from default view.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean hidden;
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public Drive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this shared drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this shared drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public Drive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this shared drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this shared drive.
* @param capabilities capabilities or {@code null} for none
*/
public Drive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public Drive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedTime() {
return createdTime;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @param createdTime createdTime or {@code null} for none
*/
public Drive setCreatedTime(com.google.api.client.util.DateTime createdTime) {
this.createdTime = createdTime;
return this;
}
/**
* Whether the shared drive is hidden from default view.
* @return value or {@code null} for none
*/
public java.lang.Boolean getHidden() {
return hidden;
}
/**
* Whether the shared drive is hidden from default view.
* @param hidden hidden or {@code null} for none
*/
public Drive setHidden(java.lang.Boolean hidden) {
this.hidden = hidden;
return this;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @param id id or {@code null} for none
*/
public Drive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @param kind kind or {@code null} for none
*/
public Drive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this shared drive.
* @param name name or {@code null} for none
*/
public Drive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @param restrictions restrictions or {@code null} for none
*/
public Drive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public Drive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public Drive set(String fieldName, Object value) {
return (Drive) super.set(fieldName, value);
}
@Override
public Drive clone() {
return (Drive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this shared drive is set.
* This is a write only field; it can only be set on drive.drives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Google Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Google Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Google Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this shared drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveBackground;
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteDrive;
/**
* Whether the current user can download files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this shared drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Whether the current user can rename files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameDrive;
/**
* Whether the current user can share files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this shared drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveBackground() {
return canChangeDriveBackground;
}
/**
* Whether the current user can change the background of this shared drive.
* @param canChangeDriveBackground canChangeDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeDriveBackground(java.lang.Boolean canChangeDriveBackground) {
this.canChangeDriveBackground = canChangeDriveBackground;
return this;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveMembersOnlyRestriction() {
return canChangeDriveMembersOnlyRestriction;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @param canChangeDriveMembersOnlyRestriction canChangeDriveMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDriveMembersOnlyRestriction(java.lang.Boolean canChangeDriveMembersOnlyRestriction) {
this.canChangeDriveMembersOnlyRestriction = canChangeDriveMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this shared drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this shared drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteDrive() {
return canDeleteDrive;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @param canDeleteDrive canDeleteDrive or {@code null} for none
*/
public Capabilities setCanDeleteDrive(java.lang.Boolean canDeleteDrive) {
this.canDeleteDrive = canDeleteDrive;
return this;
}
/**
* Whether the current user can download files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this shared drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this shared drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this shared drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameDrive() {
return canRenameDrive;
}
/**
* Whether the current user can rename this shared drive.
* @param canRenameDrive canRenameDrive or {@code null} for none
*/
public Capabilities setCanRenameDrive(java.lang.Boolean canRenameDrive) {
this.canRenameDrive = canRenameDrive;
return this;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this shared drive is restricted to its members.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean driveMembersOnly;
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDriveMembersOnly() {
return driveMembersOnly;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @param driveMembersOnly driveMembersOnly or {@code null} for none
*/
public Restrictions setDriveMembersOnly(java.lang.Boolean driveMembersOnly) {
this.driveMembersOnly = driveMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,414 | clients/google-api-services-drive/v3/1.27.0/com/google/api/services/drive/model/Drive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Representation of a shared drive.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Drive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this shared drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdTime;
/**
* Whether the shared drive is hidden from default view.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean hidden;
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public Drive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this shared drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this shared drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public Drive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this shared drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this shared drive.
* @param capabilities capabilities or {@code null} for none
*/
public Drive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public Drive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedTime() {
return createdTime;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @param createdTime createdTime or {@code null} for none
*/
public Drive setCreatedTime(com.google.api.client.util.DateTime createdTime) {
this.createdTime = createdTime;
return this;
}
/**
* Whether the shared drive is hidden from default view.
* @return value or {@code null} for none
*/
public java.lang.Boolean getHidden() {
return hidden;
}
/**
* Whether the shared drive is hidden from default view.
* @param hidden hidden or {@code null} for none
*/
public Drive setHidden(java.lang.Boolean hidden) {
this.hidden = hidden;
return this;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @param id id or {@code null} for none
*/
public Drive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @param kind kind or {@code null} for none
*/
public Drive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this shared drive.
* @param name name or {@code null} for none
*/
public Drive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @param restrictions restrictions or {@code null} for none
*/
public Drive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public Drive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public Drive set(String fieldName, Object value) {
return (Drive) super.set(fieldName, value);
}
@Override
public Drive clone() {
return (Drive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this shared drive is set.
* This is a write only field; it can only be set on drive.drives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Google Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Google Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Google Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this shared drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveBackground;
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteDrive;
/**
* Whether the current user can download files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this shared drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Whether the current user can rename files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameDrive;
/**
* Whether the current user can share files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this shared drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveBackground() {
return canChangeDriveBackground;
}
/**
* Whether the current user can change the background of this shared drive.
* @param canChangeDriveBackground canChangeDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeDriveBackground(java.lang.Boolean canChangeDriveBackground) {
this.canChangeDriveBackground = canChangeDriveBackground;
return this;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveMembersOnlyRestriction() {
return canChangeDriveMembersOnlyRestriction;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @param canChangeDriveMembersOnlyRestriction canChangeDriveMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDriveMembersOnlyRestriction(java.lang.Boolean canChangeDriveMembersOnlyRestriction) {
this.canChangeDriveMembersOnlyRestriction = canChangeDriveMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this shared drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this shared drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteDrive() {
return canDeleteDrive;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @param canDeleteDrive canDeleteDrive or {@code null} for none
*/
public Capabilities setCanDeleteDrive(java.lang.Boolean canDeleteDrive) {
this.canDeleteDrive = canDeleteDrive;
return this;
}
/**
* Whether the current user can download files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this shared drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this shared drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this shared drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameDrive() {
return canRenameDrive;
}
/**
* Whether the current user can rename this shared drive.
* @param canRenameDrive canRenameDrive or {@code null} for none
*/
public Capabilities setCanRenameDrive(java.lang.Boolean canRenameDrive) {
this.canRenameDrive = canRenameDrive;
return this;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this shared drive is restricted to its members.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean driveMembersOnly;
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDriveMembersOnly() {
return driveMembersOnly;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @param driveMembersOnly driveMembersOnly or {@code null} for none
*/
public Restrictions setDriveMembersOnly(java.lang.Boolean driveMembersOnly) {
this.driveMembersOnly = driveMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,414 | clients/google-api-services-drive/v3/1.28.0/com/google/api/services/drive/model/Drive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Representation of a shared drive.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Drive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this shared drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdTime;
/**
* Whether the shared drive is hidden from default view.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean hidden;
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public Drive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this shared drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this shared drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public Drive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this shared drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this shared drive.
* @param capabilities capabilities or {@code null} for none
*/
public Drive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public Drive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedTime() {
return createdTime;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @param createdTime createdTime or {@code null} for none
*/
public Drive setCreatedTime(com.google.api.client.util.DateTime createdTime) {
this.createdTime = createdTime;
return this;
}
/**
* Whether the shared drive is hidden from default view.
* @return value or {@code null} for none
*/
public java.lang.Boolean getHidden() {
return hidden;
}
/**
* Whether the shared drive is hidden from default view.
* @param hidden hidden or {@code null} for none
*/
public Drive setHidden(java.lang.Boolean hidden) {
this.hidden = hidden;
return this;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @param id id or {@code null} for none
*/
public Drive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @param kind kind or {@code null} for none
*/
public Drive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this shared drive.
* @param name name or {@code null} for none
*/
public Drive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @param restrictions restrictions or {@code null} for none
*/
public Drive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public Drive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public Drive set(String fieldName, Object value) {
return (Drive) super.set(fieldName, value);
}
@Override
public Drive clone() {
return (Drive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this shared drive is set.
* This is a write only field; it can only be set on drive.drives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Google Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Google Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Google Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this shared drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveBackground;
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteDrive;
/**
* Whether the current user can download files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this shared drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Whether the current user can rename files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameDrive;
/**
* Whether the current user can share files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this shared drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveBackground() {
return canChangeDriveBackground;
}
/**
* Whether the current user can change the background of this shared drive.
* @param canChangeDriveBackground canChangeDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeDriveBackground(java.lang.Boolean canChangeDriveBackground) {
this.canChangeDriveBackground = canChangeDriveBackground;
return this;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveMembersOnlyRestriction() {
return canChangeDriveMembersOnlyRestriction;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @param canChangeDriveMembersOnlyRestriction canChangeDriveMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDriveMembersOnlyRestriction(java.lang.Boolean canChangeDriveMembersOnlyRestriction) {
this.canChangeDriveMembersOnlyRestriction = canChangeDriveMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this shared drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this shared drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteDrive() {
return canDeleteDrive;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @param canDeleteDrive canDeleteDrive or {@code null} for none
*/
public Capabilities setCanDeleteDrive(java.lang.Boolean canDeleteDrive) {
this.canDeleteDrive = canDeleteDrive;
return this;
}
/**
* Whether the current user can download files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this shared drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this shared drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this shared drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameDrive() {
return canRenameDrive;
}
/**
* Whether the current user can rename this shared drive.
* @param canRenameDrive canRenameDrive or {@code null} for none
*/
public Capabilities setCanRenameDrive(java.lang.Boolean canRenameDrive) {
this.canRenameDrive = canRenameDrive;
return this;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this shared drive is restricted to its members.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean driveMembersOnly;
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDriveMembersOnly() {
return driveMembersOnly;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @param driveMembersOnly driveMembersOnly or {@code null} for none
*/
public Restrictions setDriveMembersOnly(java.lang.Boolean driveMembersOnly) {
this.driveMembersOnly = driveMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,414 | clients/google-api-services-drive/v3/1.29.2/com/google/api/services/drive/model/Drive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Representation of a shared drive.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Drive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this shared drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdTime;
/**
* Whether the shared drive is hidden from default view.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean hidden;
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public Drive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this shared drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this shared drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public Drive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this shared drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this shared drive.
* @param capabilities capabilities or {@code null} for none
*/
public Drive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public Drive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedTime() {
return createdTime;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @param createdTime createdTime or {@code null} for none
*/
public Drive setCreatedTime(com.google.api.client.util.DateTime createdTime) {
this.createdTime = createdTime;
return this;
}
/**
* Whether the shared drive is hidden from default view.
* @return value or {@code null} for none
*/
public java.lang.Boolean getHidden() {
return hidden;
}
/**
* Whether the shared drive is hidden from default view.
* @param hidden hidden or {@code null} for none
*/
public Drive setHidden(java.lang.Boolean hidden) {
this.hidden = hidden;
return this;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @param id id or {@code null} for none
*/
public Drive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @param kind kind or {@code null} for none
*/
public Drive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this shared drive.
* @param name name or {@code null} for none
*/
public Drive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @param restrictions restrictions or {@code null} for none
*/
public Drive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public Drive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public Drive set(String fieldName, Object value) {
return (Drive) super.set(fieldName, value);
}
@Override
public Drive clone() {
return (Drive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this shared drive is set.
* This is a write only field; it can only be set on drive.drives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Google Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Google Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Google Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this shared drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveBackground;
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteDrive;
/**
* Whether the current user can download files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this shared drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Whether the current user can rename files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameDrive;
/**
* Whether the current user can share files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this shared drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveBackground() {
return canChangeDriveBackground;
}
/**
* Whether the current user can change the background of this shared drive.
* @param canChangeDriveBackground canChangeDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeDriveBackground(java.lang.Boolean canChangeDriveBackground) {
this.canChangeDriveBackground = canChangeDriveBackground;
return this;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveMembersOnlyRestriction() {
return canChangeDriveMembersOnlyRestriction;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @param canChangeDriveMembersOnlyRestriction canChangeDriveMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDriveMembersOnlyRestriction(java.lang.Boolean canChangeDriveMembersOnlyRestriction) {
this.canChangeDriveMembersOnlyRestriction = canChangeDriveMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this shared drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this shared drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteDrive() {
return canDeleteDrive;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @param canDeleteDrive canDeleteDrive or {@code null} for none
*/
public Capabilities setCanDeleteDrive(java.lang.Boolean canDeleteDrive) {
this.canDeleteDrive = canDeleteDrive;
return this;
}
/**
* Whether the current user can download files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this shared drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this shared drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this shared drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameDrive() {
return canRenameDrive;
}
/**
* Whether the current user can rename this shared drive.
* @param canRenameDrive canRenameDrive or {@code null} for none
*/
public Capabilities setCanRenameDrive(java.lang.Boolean canRenameDrive) {
this.canRenameDrive = canRenameDrive;
return this;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this shared drive is restricted to its members.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean driveMembersOnly;
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDriveMembersOnly() {
return driveMembersOnly;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @param driveMembersOnly driveMembersOnly or {@code null} for none
*/
public Restrictions setDriveMembersOnly(java.lang.Boolean driveMembersOnly) {
this.driveMembersOnly = driveMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,414 | clients/google-api-services-drive/v3/1.30.1/com/google/api/services/drive/model/Drive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Representation of a shared drive.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Drive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this shared drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdTime;
/**
* Whether the shared drive is hidden from default view.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean hidden;
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this shared drive is
* set. This is a write only field; it can only be set on drive.drives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public Drive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this shared drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this shared drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public Drive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this shared drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this shared drive.
* @param capabilities capabilities or {@code null} for none
*/
public Drive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this shared drive as an RGB hex string. It can only be set on a
* drive.drives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public Drive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedTime() {
return createdTime;
}
/**
* The time at which the shared drive was created (RFC 3339 date-time).
* @param createdTime createdTime or {@code null} for none
*/
public Drive setCreatedTime(com.google.api.client.util.DateTime createdTime) {
this.createdTime = createdTime;
return this;
}
/**
* Whether the shared drive is hidden from default view.
* @return value or {@code null} for none
*/
public java.lang.Boolean getHidden() {
return hidden;
}
/**
* Whether the shared drive is hidden from default view.
* @param hidden hidden or {@code null} for none
*/
public Drive setHidden(java.lang.Boolean hidden) {
this.hidden = hidden;
return this;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this shared drive which is also the ID of the top level folder of this shared drive.
* @param id id or {@code null} for none
*/
public Drive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Identifies what kind of resource this is. Value: the fixed string "drive#drive".
* @param kind kind or {@code null} for none
*/
public Drive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this shared drive.
* @param name name or {@code null} for none
*/
public Drive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
* @param restrictions restrictions or {@code null} for none
*/
public Drive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* driveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.drives.create request, a random theme is chosen from which the background image and color
* are set. This is a write-only field; it can only be set on requests that don't set colorRgb or
* backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public Drive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public Drive set(String fieldName, Object value) {
return (Drive) super.set(fieldName, value);
}
@Override
public Drive clone() {
return (Drive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this shared drive is set.
* This is a write only field; it can only be set on drive.drives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Google Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Google Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Google Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this shared drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveBackground;
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDriveMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteDrive;
/**
* Whether the current user can download files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this shared drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Whether the current user can rename files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameDrive;
/**
* Whether the current user can share files or folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this shared drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this shared
* drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this shared drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveBackground() {
return canChangeDriveBackground;
}
/**
* Whether the current user can change the background of this shared drive.
* @param canChangeDriveBackground canChangeDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeDriveBackground(java.lang.Boolean canChangeDriveBackground) {
this.canChangeDriveBackground = canChangeDriveBackground;
return this;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDriveMembersOnlyRestriction() {
return canChangeDriveMembersOnlyRestriction;
}
/**
* Whether the current user can change the driveMembersOnly restriction of this shared drive.
* @param canChangeDriveMembersOnlyRestriction canChangeDriveMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDriveMembersOnlyRestriction(java.lang.Boolean canChangeDriveMembersOnlyRestriction) {
this.canChangeDriveMembersOnlyRestriction = canChangeDriveMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this shared drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this shared drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this shared drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteDrive() {
return canDeleteDrive;
}
/**
* Whether the current user can delete this shared drive. Attempting to delete the shared drive
* may still fail if there are untrashed items inside the shared drive.
* @param canDeleteDrive canDeleteDrive or {@code null} for none
*/
public Capabilities setCanDeleteDrive(java.lang.Boolean canDeleteDrive) {
this.canDeleteDrive = canDeleteDrive;
return this;
}
/**
* Whether the current user can download files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this shared drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this shared drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this shared drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this shared drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this shared drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this shared drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this shared drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameDrive() {
return canRenameDrive;
}
/**
* Whether the current user can rename this shared drive.
* @param canRenameDrive canRenameDrive or {@code null} for none
*/
public Capabilities setCanRenameDrive(java.lang.Boolean canRenameDrive) {
this.canRenameDrive = canRenameDrive;
return this;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this shared drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this shared drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this shared drive or items inside this shared drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this shared drive is restricted to its members.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean driveMembersOnly;
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this shared drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this shared drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this shared drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this shared drive and items inside this shared drive is restricted to users
* of the domain to which this shared drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this shared drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDriveMembersOnly() {
return driveMembersOnly;
}
/**
* Whether access to items inside this shared drive is restricted to its members.
* @param driveMembersOnly driveMembersOnly or {@code null} for none
*/
public Restrictions setDriveMembersOnly(java.lang.Boolean driveMembersOnly) {
this.driveMembersOnly = driveMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-cloud-java | 36,204 | java-backupdr/proto-google-cloud-backupdr-v1/src/main/java/com/google/cloud/backupdr/v1/ComputeInstanceDataSourceProperties.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/backupdr/v1/backupvault_gce.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.backupdr.v1;
/**
*
*
* <pre>
* ComputeInstanceDataSourceProperties represents the properties of a
* ComputeEngine resource that are stored in the DataSource.
* </pre>
*
* Protobuf type {@code google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties}
*/
public final class ComputeInstanceDataSourceProperties
extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties)
ComputeInstanceDataSourcePropertiesOrBuilder {
private static final long serialVersionUID = 0L;
// Use ComputeInstanceDataSourceProperties.newBuilder() to construct.
private ComputeInstanceDataSourceProperties(
com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ComputeInstanceDataSourceProperties() {
name_ = "";
description_ = "";
machineType_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ComputeInstanceDataSourceProperties();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.backupdr.v1.BackupvaultGceProto
.internal_static_google_cloud_backupdr_v1_ComputeInstanceDataSourceProperties_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.backupdr.v1.BackupvaultGceProto
.internal_static_google_cloud_backupdr_v1_ComputeInstanceDataSourceProperties_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties.class,
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties.Builder.class);
}
public static final int NAME_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object name_ = "";
/**
*
*
* <pre>
* Name of the compute instance backed up by the datasource.
* </pre>
*
* <code>string name = 1;</code>
*
* @return The name.
*/
@java.lang.Override
public java.lang.String getName() {
java.lang.Object ref = name_;
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();
name_ = s;
return s;
}
}
/**
*
*
* <pre>
* Name of the compute instance backed up by the datasource.
* </pre>
*
* <code>string name = 1;</code>
*
* @return The bytes for name.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int DESCRIPTION_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object description_ = "";
/**
*
*
* <pre>
* The description of the Compute Engine instance.
* </pre>
*
* <code>string description = 2;</code>
*
* @return The description.
*/
@java.lang.Override
public java.lang.String getDescription() {
java.lang.Object ref = description_;
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();
description_ = s;
return s;
}
}
/**
*
*
* <pre>
* The description of the Compute Engine instance.
* </pre>
*
* <code>string description = 2;</code>
*
* @return The bytes for description.
*/
@java.lang.Override
public com.google.protobuf.ByteString getDescriptionBytes() {
java.lang.Object ref = description_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
description_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int MACHINE_TYPE_FIELD_NUMBER = 3;
@SuppressWarnings("serial")
private volatile java.lang.Object machineType_ = "";
/**
*
*
* <pre>
* The machine type of the instance.
* </pre>
*
* <code>string machine_type = 3;</code>
*
* @return The machineType.
*/
@java.lang.Override
public java.lang.String getMachineType() {
java.lang.Object ref = machineType_;
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();
machineType_ = s;
return s;
}
}
/**
*
*
* <pre>
* The machine type of the instance.
* </pre>
*
* <code>string machine_type = 3;</code>
*
* @return The bytes for machineType.
*/
@java.lang.Override
public com.google.protobuf.ByteString getMachineTypeBytes() {
java.lang.Object ref = machineType_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
machineType_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int TOTAL_DISK_COUNT_FIELD_NUMBER = 4;
private long totalDiskCount_ = 0L;
/**
*
*
* <pre>
* The total number of disks attached to the Instance.
* </pre>
*
* <code>int64 total_disk_count = 4;</code>
*
* @return The totalDiskCount.
*/
@java.lang.Override
public long getTotalDiskCount() {
return totalDiskCount_;
}
public static final int TOTAL_DISK_SIZE_GB_FIELD_NUMBER = 5;
private long totalDiskSizeGb_ = 0L;
/**
*
*
* <pre>
* The sum of all the disk sizes.
* </pre>
*
* <code>int64 total_disk_size_gb = 5;</code>
*
* @return The totalDiskSizeGb.
*/
@java.lang.Override
public long getTotalDiskSizeGb() {
return totalDiskSizeGb_;
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, description_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(machineType_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, machineType_);
}
if (totalDiskCount_ != 0L) {
output.writeInt64(4, totalDiskCount_);
}
if (totalDiskSizeGb_ != 0L) {
output.writeInt64(5, totalDiskSizeGb_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, description_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(machineType_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, machineType_);
}
if (totalDiskCount_ != 0L) {
size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, totalDiskCount_);
}
if (totalDiskSizeGb_ != 0L) {
size += com.google.protobuf.CodedOutputStream.computeInt64Size(5, totalDiskSizeGb_);
}
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.backupdr.v1.ComputeInstanceDataSourceProperties)) {
return super.equals(obj);
}
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties other =
(com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties) obj;
if (!getName().equals(other.getName())) return false;
if (!getDescription().equals(other.getDescription())) return false;
if (!getMachineType().equals(other.getMachineType())) return false;
if (getTotalDiskCount() != other.getTotalDiskCount()) return false;
if (getTotalDiskSizeGb() != other.getTotalDiskSizeGb()) 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();
hash = (37 * hash) + NAME_FIELD_NUMBER;
hash = (53 * hash) + getName().hashCode();
hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER;
hash = (53 * hash) + getDescription().hashCode();
hash = (37 * hash) + MACHINE_TYPE_FIELD_NUMBER;
hash = (53 * hash) + getMachineType().hashCode();
hash = (37 * hash) + TOTAL_DISK_COUNT_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getTotalDiskCount());
hash = (37 * hash) + TOTAL_DISK_SIZE_GB_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getTotalDiskSizeGb());
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties 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.backupdr.v1.ComputeInstanceDataSourceProperties parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties 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.backupdr.v1.ComputeInstanceDataSourceProperties parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties 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.backupdr.v1.ComputeInstanceDataSourceProperties parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties 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.backupdr.v1.ComputeInstanceDataSourceProperties parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties 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.backupdr.v1.ComputeInstanceDataSourceProperties 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;
}
/**
*
*
* <pre>
* ComputeInstanceDataSourceProperties represents the properties of a
* ComputeEngine resource that are stored in the DataSource.
* </pre>
*
* Protobuf type {@code google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties)
com.google.cloud.backupdr.v1.ComputeInstanceDataSourcePropertiesOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.backupdr.v1.BackupvaultGceProto
.internal_static_google_cloud_backupdr_v1_ComputeInstanceDataSourceProperties_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.backupdr.v1.BackupvaultGceProto
.internal_static_google_cloud_backupdr_v1_ComputeInstanceDataSourceProperties_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties.class,
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties.Builder.class);
}
// Construct using com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
name_ = "";
description_ = "";
machineType_ = "";
totalDiskCount_ = 0L;
totalDiskSizeGb_ = 0L;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.backupdr.v1.BackupvaultGceProto
.internal_static_google_cloud_backupdr_v1_ComputeInstanceDataSourceProperties_descriptor;
}
@java.lang.Override
public com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties
getDefaultInstanceForType() {
return com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties build() {
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties buildPartial() {
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties result =
new com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.name_ = name_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.description_ = description_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.machineType_ = machineType_;
}
if (((from_bitField0_ & 0x00000008) != 0)) {
result.totalDiskCount_ = totalDiskCount_;
}
if (((from_bitField0_ & 0x00000010) != 0)) {
result.totalDiskSizeGb_ = totalDiskSizeGb_;
}
}
@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.backupdr.v1.ComputeInstanceDataSourceProperties) {
return mergeFrom((com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties other) {
if (other
== com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties.getDefaultInstance())
return this;
if (!other.getName().isEmpty()) {
name_ = other.name_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getDescription().isEmpty()) {
description_ = other.description_;
bitField0_ |= 0x00000002;
onChanged();
}
if (!other.getMachineType().isEmpty()) {
machineType_ = other.machineType_;
bitField0_ |= 0x00000004;
onChanged();
}
if (other.getTotalDiskCount() != 0L) {
setTotalDiskCount(other.getTotalDiskCount());
}
if (other.getTotalDiskSizeGb() != 0L) {
setTotalDiskSizeGb(other.getTotalDiskSizeGb());
}
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 10:
{
name_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
description_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 26:
{
machineType_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000004;
break;
} // case 26
case 32:
{
totalDiskCount_ = input.readInt64();
bitField0_ |= 0x00000008;
break;
} // case 32
case 40:
{
totalDiskSizeGb_ = input.readInt64();
bitField0_ |= 0x00000010;
break;
} // case 40
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.lang.Object name_ = "";
/**
*
*
* <pre>
* Name of the compute instance backed up by the datasource.
* </pre>
*
* <code>string name = 1;</code>
*
* @return The name.
*/
public java.lang.String getName() {
java.lang.Object ref = name_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
name_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Name of the compute instance backed up by the datasource.
* </pre>
*
* <code>string name = 1;</code>
*
* @return The bytes for name.
*/
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Name of the compute instance backed up by the datasource.
* </pre>
*
* <code>string name = 1;</code>
*
* @param value The name to set.
* @return This builder for chaining.
*/
public Builder setName(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
name_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Name of the compute instance backed up by the datasource.
* </pre>
*
* <code>string name = 1;</code>
*
* @return This builder for chaining.
*/
public Builder clearName() {
name_ = getDefaultInstance().getName();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Name of the compute instance backed up by the datasource.
* </pre>
*
* <code>string name = 1;</code>
*
* @param value The bytes for name to set.
* @return This builder for chaining.
*/
public Builder setNameBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
name_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object description_ = "";
/**
*
*
* <pre>
* The description of the Compute Engine instance.
* </pre>
*
* <code>string description = 2;</code>
*
* @return The description.
*/
public java.lang.String getDescription() {
java.lang.Object ref = description_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
description_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The description of the Compute Engine instance.
* </pre>
*
* <code>string description = 2;</code>
*
* @return The bytes for description.
*/
public com.google.protobuf.ByteString getDescriptionBytes() {
java.lang.Object ref = description_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
description_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The description of the Compute Engine instance.
* </pre>
*
* <code>string description = 2;</code>
*
* @param value The description to set.
* @return This builder for chaining.
*/
public Builder setDescription(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
description_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The description of the Compute Engine instance.
* </pre>
*
* <code>string description = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearDescription() {
description_ = getDefaultInstance().getDescription();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* The description of the Compute Engine instance.
* </pre>
*
* <code>string description = 2;</code>
*
* @param value The bytes for description to set.
* @return This builder for chaining.
*/
public Builder setDescriptionBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
description_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private java.lang.Object machineType_ = "";
/**
*
*
* <pre>
* The machine type of the instance.
* </pre>
*
* <code>string machine_type = 3;</code>
*
* @return The machineType.
*/
public java.lang.String getMachineType() {
java.lang.Object ref = machineType_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
machineType_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The machine type of the instance.
* </pre>
*
* <code>string machine_type = 3;</code>
*
* @return The bytes for machineType.
*/
public com.google.protobuf.ByteString getMachineTypeBytes() {
java.lang.Object ref = machineType_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
machineType_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The machine type of the instance.
* </pre>
*
* <code>string machine_type = 3;</code>
*
* @param value The machineType to set.
* @return This builder for chaining.
*/
public Builder setMachineType(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
machineType_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* The machine type of the instance.
* </pre>
*
* <code>string machine_type = 3;</code>
*
* @return This builder for chaining.
*/
public Builder clearMachineType() {
machineType_ = getDefaultInstance().getMachineType();
bitField0_ = (bitField0_ & ~0x00000004);
onChanged();
return this;
}
/**
*
*
* <pre>
* The machine type of the instance.
* </pre>
*
* <code>string machine_type = 3;</code>
*
* @param value The bytes for machineType to set.
* @return This builder for chaining.
*/
public Builder setMachineTypeBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
machineType_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
private long totalDiskCount_;
/**
*
*
* <pre>
* The total number of disks attached to the Instance.
* </pre>
*
* <code>int64 total_disk_count = 4;</code>
*
* @return The totalDiskCount.
*/
@java.lang.Override
public long getTotalDiskCount() {
return totalDiskCount_;
}
/**
*
*
* <pre>
* The total number of disks attached to the Instance.
* </pre>
*
* <code>int64 total_disk_count = 4;</code>
*
* @param value The totalDiskCount to set.
* @return This builder for chaining.
*/
public Builder setTotalDiskCount(long value) {
totalDiskCount_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
/**
*
*
* <pre>
* The total number of disks attached to the Instance.
* </pre>
*
* <code>int64 total_disk_count = 4;</code>
*
* @return This builder for chaining.
*/
public Builder clearTotalDiskCount() {
bitField0_ = (bitField0_ & ~0x00000008);
totalDiskCount_ = 0L;
onChanged();
return this;
}
private long totalDiskSizeGb_;
/**
*
*
* <pre>
* The sum of all the disk sizes.
* </pre>
*
* <code>int64 total_disk_size_gb = 5;</code>
*
* @return The totalDiskSizeGb.
*/
@java.lang.Override
public long getTotalDiskSizeGb() {
return totalDiskSizeGb_;
}
/**
*
*
* <pre>
* The sum of all the disk sizes.
* </pre>
*
* <code>int64 total_disk_size_gb = 5;</code>
*
* @param value The totalDiskSizeGb to set.
* @return This builder for chaining.
*/
public Builder setTotalDiskSizeGb(long value) {
totalDiskSizeGb_ = value;
bitField0_ |= 0x00000010;
onChanged();
return this;
}
/**
*
*
* <pre>
* The sum of all the disk sizes.
* </pre>
*
* <code>int64 total_disk_size_gb = 5;</code>
*
* @return This builder for chaining.
*/
public Builder clearTotalDiskSizeGb() {
bitField0_ = (bitField0_ & ~0x00000010);
totalDiskSizeGb_ = 0L;
onChanged();
return this;
}
@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.backupdr.v1.ComputeInstanceDataSourceProperties)
}
// @@protoc_insertion_point(class_scope:google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties)
private static final com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties();
}
public static com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ComputeInstanceDataSourceProperties> PARSER =
new com.google.protobuf.AbstractParser<ComputeInstanceDataSourceProperties>() {
@java.lang.Override
public ComputeInstanceDataSourceProperties 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<ComputeInstanceDataSourceProperties> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ComputeInstanceDataSourceProperties> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.backupdr.v1.ComputeInstanceDataSourceProperties
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,229 | java-vmmigration/proto-google-cloud-vmmigration-v1/src/main/java/com/google/cloud/vmmigration/v1/VmUtilizationMetrics.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/vmmigration/v1/vmmigration.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.vmmigration.v1;
/**
*
*
* <pre>
* Utilization metrics values for a single VM.
* </pre>
*
* Protobuf type {@code google.cloud.vmmigration.v1.VmUtilizationMetrics}
*/
public final class VmUtilizationMetrics extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.vmmigration.v1.VmUtilizationMetrics)
VmUtilizationMetricsOrBuilder {
private static final long serialVersionUID = 0L;
// Use VmUtilizationMetrics.newBuilder() to construct.
private VmUtilizationMetrics(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private VmUtilizationMetrics() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new VmUtilizationMetrics();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.vmmigration.v1.VmMigrationProto
.internal_static_google_cloud_vmmigration_v1_VmUtilizationMetrics_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.vmmigration.v1.VmMigrationProto
.internal_static_google_cloud_vmmigration_v1_VmUtilizationMetrics_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.vmmigration.v1.VmUtilizationMetrics.class,
com.google.cloud.vmmigration.v1.VmUtilizationMetrics.Builder.class);
}
public static final int CPU_MAX_PERCENT_FIELD_NUMBER = 9;
private int cpuMaxPercent_ = 0;
/**
*
*
* <pre>
* Max CPU usage, percent.
* </pre>
*
* <code>int32 cpu_max_percent = 9;</code>
*
* @return The cpuMaxPercent.
*/
@java.lang.Override
public int getCpuMaxPercent() {
return cpuMaxPercent_;
}
public static final int CPU_AVERAGE_PERCENT_FIELD_NUMBER = 10;
private int cpuAveragePercent_ = 0;
/**
*
*
* <pre>
* Average CPU usage, percent.
* </pre>
*
* <code>int32 cpu_average_percent = 10;</code>
*
* @return The cpuAveragePercent.
*/
@java.lang.Override
public int getCpuAveragePercent() {
return cpuAveragePercent_;
}
public static final int MEMORY_MAX_PERCENT_FIELD_NUMBER = 11;
private int memoryMaxPercent_ = 0;
/**
*
*
* <pre>
* Max memory usage, percent.
* </pre>
*
* <code>int32 memory_max_percent = 11;</code>
*
* @return The memoryMaxPercent.
*/
@java.lang.Override
public int getMemoryMaxPercent() {
return memoryMaxPercent_;
}
public static final int MEMORY_AVERAGE_PERCENT_FIELD_NUMBER = 12;
private int memoryAveragePercent_ = 0;
/**
*
*
* <pre>
* Average memory usage, percent.
* </pre>
*
* <code>int32 memory_average_percent = 12;</code>
*
* @return The memoryAveragePercent.
*/
@java.lang.Override
public int getMemoryAveragePercent() {
return memoryAveragePercent_;
}
public static final int DISK_IO_RATE_MAX_KBPS_FIELD_NUMBER = 13;
private long diskIoRateMaxKbps_ = 0L;
/**
*
*
* <pre>
* Max disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_max_kbps = 13;</code>
*
* @return The diskIoRateMaxKbps.
*/
@java.lang.Override
public long getDiskIoRateMaxKbps() {
return diskIoRateMaxKbps_;
}
public static final int DISK_IO_RATE_AVERAGE_KBPS_FIELD_NUMBER = 14;
private long diskIoRateAverageKbps_ = 0L;
/**
*
*
* <pre>
* Average disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_average_kbps = 14;</code>
*
* @return The diskIoRateAverageKbps.
*/
@java.lang.Override
public long getDiskIoRateAverageKbps() {
return diskIoRateAverageKbps_;
}
public static final int NETWORK_THROUGHPUT_MAX_KBPS_FIELD_NUMBER = 15;
private long networkThroughputMaxKbps_ = 0L;
/**
*
*
* <pre>
* Max network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_max_kbps = 15;</code>
*
* @return The networkThroughputMaxKbps.
*/
@java.lang.Override
public long getNetworkThroughputMaxKbps() {
return networkThroughputMaxKbps_;
}
public static final int NETWORK_THROUGHPUT_AVERAGE_KBPS_FIELD_NUMBER = 16;
private long networkThroughputAverageKbps_ = 0L;
/**
*
*
* <pre>
* Average network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_average_kbps = 16;</code>
*
* @return The networkThroughputAverageKbps.
*/
@java.lang.Override
public long getNetworkThroughputAverageKbps() {
return networkThroughputAverageKbps_;
}
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 (cpuMaxPercent_ != 0) {
output.writeInt32(9, cpuMaxPercent_);
}
if (cpuAveragePercent_ != 0) {
output.writeInt32(10, cpuAveragePercent_);
}
if (memoryMaxPercent_ != 0) {
output.writeInt32(11, memoryMaxPercent_);
}
if (memoryAveragePercent_ != 0) {
output.writeInt32(12, memoryAveragePercent_);
}
if (diskIoRateMaxKbps_ != 0L) {
output.writeInt64(13, diskIoRateMaxKbps_);
}
if (diskIoRateAverageKbps_ != 0L) {
output.writeInt64(14, diskIoRateAverageKbps_);
}
if (networkThroughputMaxKbps_ != 0L) {
output.writeInt64(15, networkThroughputMaxKbps_);
}
if (networkThroughputAverageKbps_ != 0L) {
output.writeInt64(16, networkThroughputAverageKbps_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (cpuMaxPercent_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(9, cpuMaxPercent_);
}
if (cpuAveragePercent_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(10, cpuAveragePercent_);
}
if (memoryMaxPercent_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(11, memoryMaxPercent_);
}
if (memoryAveragePercent_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(12, memoryAveragePercent_);
}
if (diskIoRateMaxKbps_ != 0L) {
size += com.google.protobuf.CodedOutputStream.computeInt64Size(13, diskIoRateMaxKbps_);
}
if (diskIoRateAverageKbps_ != 0L) {
size += com.google.protobuf.CodedOutputStream.computeInt64Size(14, diskIoRateAverageKbps_);
}
if (networkThroughputMaxKbps_ != 0L) {
size += com.google.protobuf.CodedOutputStream.computeInt64Size(15, networkThroughputMaxKbps_);
}
if (networkThroughputAverageKbps_ != 0L) {
size +=
com.google.protobuf.CodedOutputStream.computeInt64Size(16, networkThroughputAverageKbps_);
}
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.vmmigration.v1.VmUtilizationMetrics)) {
return super.equals(obj);
}
com.google.cloud.vmmigration.v1.VmUtilizationMetrics other =
(com.google.cloud.vmmigration.v1.VmUtilizationMetrics) obj;
if (getCpuMaxPercent() != other.getCpuMaxPercent()) return false;
if (getCpuAveragePercent() != other.getCpuAveragePercent()) return false;
if (getMemoryMaxPercent() != other.getMemoryMaxPercent()) return false;
if (getMemoryAveragePercent() != other.getMemoryAveragePercent()) return false;
if (getDiskIoRateMaxKbps() != other.getDiskIoRateMaxKbps()) return false;
if (getDiskIoRateAverageKbps() != other.getDiskIoRateAverageKbps()) return false;
if (getNetworkThroughputMaxKbps() != other.getNetworkThroughputMaxKbps()) return false;
if (getNetworkThroughputAverageKbps() != other.getNetworkThroughputAverageKbps()) 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();
hash = (37 * hash) + CPU_MAX_PERCENT_FIELD_NUMBER;
hash = (53 * hash) + getCpuMaxPercent();
hash = (37 * hash) + CPU_AVERAGE_PERCENT_FIELD_NUMBER;
hash = (53 * hash) + getCpuAveragePercent();
hash = (37 * hash) + MEMORY_MAX_PERCENT_FIELD_NUMBER;
hash = (53 * hash) + getMemoryMaxPercent();
hash = (37 * hash) + MEMORY_AVERAGE_PERCENT_FIELD_NUMBER;
hash = (53 * hash) + getMemoryAveragePercent();
hash = (37 * hash) + DISK_IO_RATE_MAX_KBPS_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getDiskIoRateMaxKbps());
hash = (37 * hash) + DISK_IO_RATE_AVERAGE_KBPS_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getDiskIoRateAverageKbps());
hash = (37 * hash) + NETWORK_THROUGHPUT_MAX_KBPS_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getNetworkThroughputMaxKbps());
hash = (37 * hash) + NETWORK_THROUGHPUT_AVERAGE_KBPS_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getNetworkThroughputAverageKbps());
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics 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.vmmigration.v1.VmUtilizationMetrics parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics 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.vmmigration.v1.VmUtilizationMetrics parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics 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.vmmigration.v1.VmUtilizationMetrics parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics 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.vmmigration.v1.VmUtilizationMetrics parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics 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.vmmigration.v1.VmUtilizationMetrics 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;
}
/**
*
*
* <pre>
* Utilization metrics values for a single VM.
* </pre>
*
* Protobuf type {@code google.cloud.vmmigration.v1.VmUtilizationMetrics}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.vmmigration.v1.VmUtilizationMetrics)
com.google.cloud.vmmigration.v1.VmUtilizationMetricsOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.vmmigration.v1.VmMigrationProto
.internal_static_google_cloud_vmmigration_v1_VmUtilizationMetrics_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.vmmigration.v1.VmMigrationProto
.internal_static_google_cloud_vmmigration_v1_VmUtilizationMetrics_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.vmmigration.v1.VmUtilizationMetrics.class,
com.google.cloud.vmmigration.v1.VmUtilizationMetrics.Builder.class);
}
// Construct using com.google.cloud.vmmigration.v1.VmUtilizationMetrics.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
cpuMaxPercent_ = 0;
cpuAveragePercent_ = 0;
memoryMaxPercent_ = 0;
memoryAveragePercent_ = 0;
diskIoRateMaxKbps_ = 0L;
diskIoRateAverageKbps_ = 0L;
networkThroughputMaxKbps_ = 0L;
networkThroughputAverageKbps_ = 0L;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.vmmigration.v1.VmMigrationProto
.internal_static_google_cloud_vmmigration_v1_VmUtilizationMetrics_descriptor;
}
@java.lang.Override
public com.google.cloud.vmmigration.v1.VmUtilizationMetrics getDefaultInstanceForType() {
return com.google.cloud.vmmigration.v1.VmUtilizationMetrics.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.vmmigration.v1.VmUtilizationMetrics build() {
com.google.cloud.vmmigration.v1.VmUtilizationMetrics result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.vmmigration.v1.VmUtilizationMetrics buildPartial() {
com.google.cloud.vmmigration.v1.VmUtilizationMetrics result =
new com.google.cloud.vmmigration.v1.VmUtilizationMetrics(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.vmmigration.v1.VmUtilizationMetrics result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.cpuMaxPercent_ = cpuMaxPercent_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.cpuAveragePercent_ = cpuAveragePercent_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.memoryMaxPercent_ = memoryMaxPercent_;
}
if (((from_bitField0_ & 0x00000008) != 0)) {
result.memoryAveragePercent_ = memoryAveragePercent_;
}
if (((from_bitField0_ & 0x00000010) != 0)) {
result.diskIoRateMaxKbps_ = diskIoRateMaxKbps_;
}
if (((from_bitField0_ & 0x00000020) != 0)) {
result.diskIoRateAverageKbps_ = diskIoRateAverageKbps_;
}
if (((from_bitField0_ & 0x00000040) != 0)) {
result.networkThroughputMaxKbps_ = networkThroughputMaxKbps_;
}
if (((from_bitField0_ & 0x00000080) != 0)) {
result.networkThroughputAverageKbps_ = networkThroughputAverageKbps_;
}
}
@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.vmmigration.v1.VmUtilizationMetrics) {
return mergeFrom((com.google.cloud.vmmigration.v1.VmUtilizationMetrics) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.vmmigration.v1.VmUtilizationMetrics other) {
if (other == com.google.cloud.vmmigration.v1.VmUtilizationMetrics.getDefaultInstance())
return this;
if (other.getCpuMaxPercent() != 0) {
setCpuMaxPercent(other.getCpuMaxPercent());
}
if (other.getCpuAveragePercent() != 0) {
setCpuAveragePercent(other.getCpuAveragePercent());
}
if (other.getMemoryMaxPercent() != 0) {
setMemoryMaxPercent(other.getMemoryMaxPercent());
}
if (other.getMemoryAveragePercent() != 0) {
setMemoryAveragePercent(other.getMemoryAveragePercent());
}
if (other.getDiskIoRateMaxKbps() != 0L) {
setDiskIoRateMaxKbps(other.getDiskIoRateMaxKbps());
}
if (other.getDiskIoRateAverageKbps() != 0L) {
setDiskIoRateAverageKbps(other.getDiskIoRateAverageKbps());
}
if (other.getNetworkThroughputMaxKbps() != 0L) {
setNetworkThroughputMaxKbps(other.getNetworkThroughputMaxKbps());
}
if (other.getNetworkThroughputAverageKbps() != 0L) {
setNetworkThroughputAverageKbps(other.getNetworkThroughputAverageKbps());
}
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 72:
{
cpuMaxPercent_ = input.readInt32();
bitField0_ |= 0x00000001;
break;
} // case 72
case 80:
{
cpuAveragePercent_ = input.readInt32();
bitField0_ |= 0x00000002;
break;
} // case 80
case 88:
{
memoryMaxPercent_ = input.readInt32();
bitField0_ |= 0x00000004;
break;
} // case 88
case 96:
{
memoryAveragePercent_ = input.readInt32();
bitField0_ |= 0x00000008;
break;
} // case 96
case 104:
{
diskIoRateMaxKbps_ = input.readInt64();
bitField0_ |= 0x00000010;
break;
} // case 104
case 112:
{
diskIoRateAverageKbps_ = input.readInt64();
bitField0_ |= 0x00000020;
break;
} // case 112
case 120:
{
networkThroughputMaxKbps_ = input.readInt64();
bitField0_ |= 0x00000040;
break;
} // case 120
case 128:
{
networkThroughputAverageKbps_ = input.readInt64();
bitField0_ |= 0x00000080;
break;
} // case 128
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 int cpuMaxPercent_;
/**
*
*
* <pre>
* Max CPU usage, percent.
* </pre>
*
* <code>int32 cpu_max_percent = 9;</code>
*
* @return The cpuMaxPercent.
*/
@java.lang.Override
public int getCpuMaxPercent() {
return cpuMaxPercent_;
}
/**
*
*
* <pre>
* Max CPU usage, percent.
* </pre>
*
* <code>int32 cpu_max_percent = 9;</code>
*
* @param value The cpuMaxPercent to set.
* @return This builder for chaining.
*/
public Builder setCpuMaxPercent(int value) {
cpuMaxPercent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Max CPU usage, percent.
* </pre>
*
* <code>int32 cpu_max_percent = 9;</code>
*
* @return This builder for chaining.
*/
public Builder clearCpuMaxPercent() {
bitField0_ = (bitField0_ & ~0x00000001);
cpuMaxPercent_ = 0;
onChanged();
return this;
}
private int cpuAveragePercent_;
/**
*
*
* <pre>
* Average CPU usage, percent.
* </pre>
*
* <code>int32 cpu_average_percent = 10;</code>
*
* @return The cpuAveragePercent.
*/
@java.lang.Override
public int getCpuAveragePercent() {
return cpuAveragePercent_;
}
/**
*
*
* <pre>
* Average CPU usage, percent.
* </pre>
*
* <code>int32 cpu_average_percent = 10;</code>
*
* @param value The cpuAveragePercent to set.
* @return This builder for chaining.
*/
public Builder setCpuAveragePercent(int value) {
cpuAveragePercent_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Average CPU usage, percent.
* </pre>
*
* <code>int32 cpu_average_percent = 10;</code>
*
* @return This builder for chaining.
*/
public Builder clearCpuAveragePercent() {
bitField0_ = (bitField0_ & ~0x00000002);
cpuAveragePercent_ = 0;
onChanged();
return this;
}
private int memoryMaxPercent_;
/**
*
*
* <pre>
* Max memory usage, percent.
* </pre>
*
* <code>int32 memory_max_percent = 11;</code>
*
* @return The memoryMaxPercent.
*/
@java.lang.Override
public int getMemoryMaxPercent() {
return memoryMaxPercent_;
}
/**
*
*
* <pre>
* Max memory usage, percent.
* </pre>
*
* <code>int32 memory_max_percent = 11;</code>
*
* @param value The memoryMaxPercent to set.
* @return This builder for chaining.
*/
public Builder setMemoryMaxPercent(int value) {
memoryMaxPercent_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* Max memory usage, percent.
* </pre>
*
* <code>int32 memory_max_percent = 11;</code>
*
* @return This builder for chaining.
*/
public Builder clearMemoryMaxPercent() {
bitField0_ = (bitField0_ & ~0x00000004);
memoryMaxPercent_ = 0;
onChanged();
return this;
}
private int memoryAveragePercent_;
/**
*
*
* <pre>
* Average memory usage, percent.
* </pre>
*
* <code>int32 memory_average_percent = 12;</code>
*
* @return The memoryAveragePercent.
*/
@java.lang.Override
public int getMemoryAveragePercent() {
return memoryAveragePercent_;
}
/**
*
*
* <pre>
* Average memory usage, percent.
* </pre>
*
* <code>int32 memory_average_percent = 12;</code>
*
* @param value The memoryAveragePercent to set.
* @return This builder for chaining.
*/
public Builder setMemoryAveragePercent(int value) {
memoryAveragePercent_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
/**
*
*
* <pre>
* Average memory usage, percent.
* </pre>
*
* <code>int32 memory_average_percent = 12;</code>
*
* @return This builder for chaining.
*/
public Builder clearMemoryAveragePercent() {
bitField0_ = (bitField0_ & ~0x00000008);
memoryAveragePercent_ = 0;
onChanged();
return this;
}
private long diskIoRateMaxKbps_;
/**
*
*
* <pre>
* Max disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_max_kbps = 13;</code>
*
* @return The diskIoRateMaxKbps.
*/
@java.lang.Override
public long getDiskIoRateMaxKbps() {
return diskIoRateMaxKbps_;
}
/**
*
*
* <pre>
* Max disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_max_kbps = 13;</code>
*
* @param value The diskIoRateMaxKbps to set.
* @return This builder for chaining.
*/
public Builder setDiskIoRateMaxKbps(long value) {
diskIoRateMaxKbps_ = value;
bitField0_ |= 0x00000010;
onChanged();
return this;
}
/**
*
*
* <pre>
* Max disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_max_kbps = 13;</code>
*
* @return This builder for chaining.
*/
public Builder clearDiskIoRateMaxKbps() {
bitField0_ = (bitField0_ & ~0x00000010);
diskIoRateMaxKbps_ = 0L;
onChanged();
return this;
}
private long diskIoRateAverageKbps_;
/**
*
*
* <pre>
* Average disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_average_kbps = 14;</code>
*
* @return The diskIoRateAverageKbps.
*/
@java.lang.Override
public long getDiskIoRateAverageKbps() {
return diskIoRateAverageKbps_;
}
/**
*
*
* <pre>
* Average disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_average_kbps = 14;</code>
*
* @param value The diskIoRateAverageKbps to set.
* @return This builder for chaining.
*/
public Builder setDiskIoRateAverageKbps(long value) {
diskIoRateAverageKbps_ = value;
bitField0_ |= 0x00000020;
onChanged();
return this;
}
/**
*
*
* <pre>
* Average disk IO rate, in kilobytes per second.
* </pre>
*
* <code>int64 disk_io_rate_average_kbps = 14;</code>
*
* @return This builder for chaining.
*/
public Builder clearDiskIoRateAverageKbps() {
bitField0_ = (bitField0_ & ~0x00000020);
diskIoRateAverageKbps_ = 0L;
onChanged();
return this;
}
private long networkThroughputMaxKbps_;
/**
*
*
* <pre>
* Max network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_max_kbps = 15;</code>
*
* @return The networkThroughputMaxKbps.
*/
@java.lang.Override
public long getNetworkThroughputMaxKbps() {
return networkThroughputMaxKbps_;
}
/**
*
*
* <pre>
* Max network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_max_kbps = 15;</code>
*
* @param value The networkThroughputMaxKbps to set.
* @return This builder for chaining.
*/
public Builder setNetworkThroughputMaxKbps(long value) {
networkThroughputMaxKbps_ = value;
bitField0_ |= 0x00000040;
onChanged();
return this;
}
/**
*
*
* <pre>
* Max network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_max_kbps = 15;</code>
*
* @return This builder for chaining.
*/
public Builder clearNetworkThroughputMaxKbps() {
bitField0_ = (bitField0_ & ~0x00000040);
networkThroughputMaxKbps_ = 0L;
onChanged();
return this;
}
private long networkThroughputAverageKbps_;
/**
*
*
* <pre>
* Average network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_average_kbps = 16;</code>
*
* @return The networkThroughputAverageKbps.
*/
@java.lang.Override
public long getNetworkThroughputAverageKbps() {
return networkThroughputAverageKbps_;
}
/**
*
*
* <pre>
* Average network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_average_kbps = 16;</code>
*
* @param value The networkThroughputAverageKbps to set.
* @return This builder for chaining.
*/
public Builder setNetworkThroughputAverageKbps(long value) {
networkThroughputAverageKbps_ = value;
bitField0_ |= 0x00000080;
onChanged();
return this;
}
/**
*
*
* <pre>
* Average network throughput (combined transmit-rates and receive-rates), in
* kilobytes per second.
* </pre>
*
* <code>int64 network_throughput_average_kbps = 16;</code>
*
* @return This builder for chaining.
*/
public Builder clearNetworkThroughputAverageKbps() {
bitField0_ = (bitField0_ & ~0x00000080);
networkThroughputAverageKbps_ = 0L;
onChanged();
return this;
}
@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.vmmigration.v1.VmUtilizationMetrics)
}
// @@protoc_insertion_point(class_scope:google.cloud.vmmigration.v1.VmUtilizationMetrics)
private static final com.google.cloud.vmmigration.v1.VmUtilizationMetrics DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.vmmigration.v1.VmUtilizationMetrics();
}
public static com.google.cloud.vmmigration.v1.VmUtilizationMetrics getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<VmUtilizationMetrics> PARSER =
new com.google.protobuf.AbstractParser<VmUtilizationMetrics>() {
@java.lang.Override
public VmUtilizationMetrics 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<VmUtilizationMetrics> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<VmUtilizationMetrics> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.vmmigration.v1.VmUtilizationMetrics getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/incubator-kie-drools | 34,924 | drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveRulesAdvOperatorsTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.drools.compiler.integrationtests.incrementalcompilation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.kie.api.runtime.KieSession;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests adding and removing rules with advanced operators.
*/
@EnabledIfSystemProperty(named = "runTurtleTests", matches = "true")
public class AddRemoveRulesAdvOperatorsTest {
@Test
public void testAddRemoveSameRuleWithContains() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveSameRuleWithContainsSwitchedConstraints() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" java.util.Map(values() contains \"1\") \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveRuleWithContainsAndExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" exists(String()) \n" +
" java.util.Map(values() contains \"1\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveRuleWithContainsAndExistsAtEnd() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" exists(String()) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveRuleWithContainsAndExistsAtBeg() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" exists(String()) \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
// TODO - the next two tests are same as tests
// testAddRemoveRuleWithContainsAndExistsAtBeg and testAddRemoveRuleWithContainsAndExistsAtEnd
// (in each test the rule order is also switched),
// but keeping them here, because some fails occur sooner in the test here than in previous tests.
// (in other words, when previous tests fail soon, the fail that will occur later in the test is not
// visible, until the first one is fixed)
@Test
public void testAddRemoveRuleWithContainsAndExistsInFirstRuleAtBeg() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" exists(String()) \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveRuleWithContainsAndExistsInFirstRuleAtEnd() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" exists(String()) \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveRuleWithContainsAndDoubledExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" exists(String() and String()) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveRuleWithNotContainsAndExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() not contains \"2\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" exists(String()) \n" +
" java.util.Map(values() not contains \"2\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveRuleWithContainsAndNotContainsAndExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" java.util.Map(values() contains \"1\") \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" exists(String()) \n" +
" java.util.Map(values() not contains \"2\") \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, getFactsContains());
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, null, getFactsContains());
}
@Test
public void testAddRemoveSameRuleWithMemberOf() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" $s: String($s memberOf memberList) \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" $s: String($s memberOf memberList) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString);
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString);
}
@Test
public void testAddRemoveSameRuleWithMemberOfSwitchedConstraints() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" $s: String($s memberOf memberList) \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" $s: String($s memberOf memberList) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString);
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString);
}
@Test
public void testAddRemoveRuleWithMemberOfAndExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" $s: String($s memberOf memberList) \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" exists(String()) \n" +
" $s: String($s memberOf memberList) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString);
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString);
}
@Test
public void testAddRemoveRuleWithMemberOfAndExistsAtEnd() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" $s: String($s memberOf memberList) \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" $s: String($s memberOf memberList) \n" +
" exists(String()) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString);
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString);
}
@Test
public void testAddRemoveRuleWithMemberOfAndExistsAtBeg() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" $s: String($s memberOf memberList) \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" exists(String()) \n" +
" String() \n" +
" $s: String($s memberOf memberList) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString);
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString);
}
@Test
public void testAddRemoveRuleWithMemberOfAndNotExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" $s: String($s memberOf memberList) \n" +
" not(exists(Integer() and Integer())) \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" $s: String($s memberOf memberList) \n" +
" not(exists(Integer() and Integer())) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString);
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString);
}
@Test
public void testAddRemoveRuleWithNotMemberOfAndExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" $s: String($s not memberOf memberList) \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" exists(String()) \n" +
" $s: String($s not memberOf memberList) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf("test"), "fact");
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf("test"), "fact");
}
@Test
public void testAddRemoveRuleWithMemberOfAndNotMemberOfAndExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" $s: String($s memberOf memberList) \n" +
" String() \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" exists(String()) \n" +
" $s: String($s not memberOf memberList) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString, "fact");
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString, "fact");
}
@Test
@Disabled
public void testAddRemoveRuleWithContainsMatchesExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE1_NAME + " \n" +
" when \n" +
" String() \n" +
" $s: String($s matches \"tes.*\") \n" +
" exists(String()) \n" +
" String($s memberOf memberList) \n" +
" then \n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
" end";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";\n" +
" global java.util.List memberList\n" +
" global java.util.List list \n" +
" rule " + TestUtil.RULE2_NAME + " \n" +
" when \n" +
" String() \n" +
" $s: String($s matches \"tes.*\") \n" +
" String($s memberOf memberList) \n" +
" java.util.Map(values() contains \"1\") \n" +
" exists(String() and String()) \n" +
" exists(String()) \n" +
" then\n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
" end";
final String memberString = "test";
AddRemoveTestCases.runAllTestCases(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, getGlobalsMemberOf(memberString), memberString, "1");
AddRemoveTestCases.runAllTestCases(rule2, rule1, TestUtil.RULE2_NAME, TestUtil.RULE1_NAME, getGlobalsMemberOf(memberString), memberString, "1");
}
@Test
public void testAddRemoveRuleContainsExists3Rules() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" +
"global java.util.concurrent.atomic.AtomicInteger globalInt\n" +
"global java.util.List list\n" +
"rule " + TestUtil.RULE1_NAME + " \n" +
"when\n" +
" $s : String()\n" +
" Integer() \n" +
" java.util.Map(values() contains \"1\") \n" +
" exists( Integer() and Integer() )\n" +
"then\n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
"end\n";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" +
"global java.util.concurrent.atomic.AtomicInteger globalInt\n" +
"global java.util.List list\n" +
"rule " + TestUtil.RULE2_NAME + " \n" +
"when \n" +
" $s : String()\n" +
" Integer() \n" +
" java.util.Map(values() contains \"1\") \n" +
" exists( Integer() and Integer() )\n" +
" String()\n" +
"then \n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
"end";
final String rule3 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" +
"global java.util.concurrent.atomic.AtomicInteger globalInt\n" +
"global java.util.List list\n" +
"rule " + TestUtil.RULE3_NAME + " \n" +
"when \n" +
" $s : String()\n" +
" java.util.Map(values() contains \"1\") \n" +
" exists( Integer() and exists(Integer() and Integer()))\n" +
" String()\n" +
"then \n" +
" list.add('" + TestUtil.RULE3_NAME + "'); \n" +
"end";
final Map<Object, String> mapFact = new HashMap<>(1);
mapFact.put(new Object(), "1");
final KieSession kieSession = TestUtil.buildSessionInSteps(rule1);
try {
final List<String> resultsList = new ArrayList<>();
kieSession.setGlobal("list", resultsList);
kieSession.setGlobal("globalInt", new AtomicInteger(0));
TestUtil.insertFacts(kieSession, mapFact, 1, "1");
kieSession.fireAllRules();
assertThat(resultsList).containsOnly(TestUtil.RULE1_NAME);
resultsList.clear();
TestUtil.addRules(kieSession, rule2);
kieSession.fireAllRules();
assertThat(resultsList).containsOnly(TestUtil.RULE2_NAME);
resultsList.clear();
TestUtil.addRules(kieSession, rule3);
kieSession.fireAllRules();
assertThat(resultsList).containsOnly(TestUtil.RULE3_NAME);
resultsList.clear();
TestUtil.removeRules(kieSession, TestUtil.RULES_PACKAGE_NAME, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, TestUtil.RULE3_NAME);
kieSession.fireAllRules();
assertThat(resultsList).isEmpty();
} finally {
kieSession.dispose();
}
}
@Test
@Timeout(10000L)
public void testAddRemoveRuleContainsExists3RulesDoubledExists() {
final String rule1 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" +
"global java.util.concurrent.atomic.AtomicInteger globalInt\n" +
"global java.util.List list\n" +
"rule " + TestUtil.RULE1_NAME + " \n" +
"when\n" +
" $s : String()\n" +
" Integer() \n" +
" java.util.Map(values() contains \"1\") \n" +
" exists( Integer() and Integer() )\n" +
"then\n" +
" list.add('" + TestUtil.RULE1_NAME + "'); \n" +
"end\n";
final String rule2 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" +
"global java.util.concurrent.atomic.AtomicInteger globalInt\n" +
"global java.util.List list\n" +
"rule " + TestUtil.RULE2_NAME + " \n" +
"when \n" +
" $s : String()\n" +
" Integer() \n" +
" exists( Integer() and Integer() )\n" +
" java.util.Map(values() contains \"1\") \n" +
" exists( Integer() and Integer() )\n" +
" String()\n" +
"then \n" +
" list.add('" + TestUtil.RULE2_NAME + "'); \n" +
"end";
final String rule3 = "package " + TestUtil.RULES_PACKAGE_NAME + ";" +
"global java.util.concurrent.atomic.AtomicInteger globalInt\n" +
"global java.util.List list\n" +
"rule " + TestUtil.RULE3_NAME + " \n" +
"when \n" +
" $s : String()\n" +
" java.util.Map(values() contains \"1\") \n" +
" exists( Integer() and exists(Integer() and Integer()))\n" +
" String()\n" +
"then \n" +
" list.add('" + TestUtil.RULE3_NAME + "'); \n" +
"end";
final Map<Object, String> mapFact = new HashMap<>(1);
mapFact.put(new Object(), "1");
final KieSession kieSession = TestUtil.buildSessionInSteps(rule1);
try {
final List<String> resultsList = new ArrayList<>();
kieSession.setGlobal("list", resultsList);
kieSession.setGlobal("globalInt", new AtomicInteger(0));
TestUtil.insertFacts(kieSession, mapFact, 1, "1");
kieSession.fireAllRules();
assertThat(resultsList).containsOnly(TestUtil.RULE1_NAME);
resultsList.clear();
TestUtil.addRules(kieSession, rule2);
kieSession.fireAllRules();
assertThat(resultsList).containsOnly(TestUtil.RULE2_NAME);
resultsList.clear();
TestUtil.addRules(kieSession, rule3);
kieSession.fireAllRules();
assertThat(resultsList).containsOnly(TestUtil.RULE3_NAME);
resultsList.clear();
TestUtil.removeRules(kieSession, TestUtil.RULES_PACKAGE_NAME, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, TestUtil.RULE3_NAME);
kieSession.fireAllRules();
assertThat(resultsList).isEmpty();
} finally {
kieSession.dispose();
}
}
private Object[] getFactsContains() {
final Map<Object, String> mapFact = new HashMap<>(1);
mapFact.put(new Object(), "1");
return new Object[]{mapFact, 1, 2, "1"};
}
private Map<String, Object> getGlobalsMemberOf(final String memberString) {
final Map<String, Object> globals = new HashMap<>(1);
final List<String> memberList = new ArrayList<>(1);
memberList.add(memberString);
globals.put("memberList", memberList);
return globals;
}
}
|
googleapis/google-cloud-java | 36,201 | java-enterpriseknowledgegraph/proto-google-cloud-enterpriseknowledgegraph-v1/src/main/java/com/google/cloud/enterpriseknowledgegraph/v1/ListEntityReconciliationJobsRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/enterpriseknowledgegraph/v1/service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.enterpriseknowledgegraph.v1;
/**
*
*
* <pre>
* Request message for
* [EnterpriseKnowledgeGraphService.ListEntityReconciliationJobs][google.cloud.enterpriseknowledgegraph.v1.EnterpriseKnowledgeGraphService.ListEntityReconciliationJobs].
* </pre>
*
* Protobuf type {@code
* google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest}
*/
public final class ListEntityReconciliationJobsRequest
extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest)
ListEntityReconciliationJobsRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListEntityReconciliationJobsRequest.newBuilder() to construct.
private ListEntityReconciliationJobsRequest(
com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListEntityReconciliationJobsRequest() {
parent_ = "";
filter_ = "";
pageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListEntityReconciliationJobsRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.enterpriseknowledgegraph.v1.ServiceProto
.internal_static_google_cloud_enterpriseknowledgegraph_v1_ListEntityReconciliationJobsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.enterpriseknowledgegraph.v1.ServiceProto
.internal_static_google_cloud_enterpriseknowledgegraph_v1_ListEntityReconciliationJobsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest.class,
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest.Builder
.class);
}
public static final int PARENT_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The name of the EntityReconciliationJob's parent resource.
* Format: `projects/{project}/locations/{location}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The name of the EntityReconciliationJob's parent resource.
* Format: `projects/{project}/locations/{location}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int FILTER_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object filter_ = "";
/**
*
*
* <pre>
* An expression for filtering the results of the request. For field names
* both snake_case and camelCase are supported.
* </pre>
*
* <code>string filter = 2;</code>
*
* @return The filter.
*/
@java.lang.Override
public java.lang.String getFilter() {
java.lang.Object ref = filter_;
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();
filter_ = s;
return s;
}
}
/**
*
*
* <pre>
* An expression for filtering the results of the request. For field names
* both snake_case and camelCase are supported.
* </pre>
*
* <code>string filter = 2;</code>
*
* @return The bytes for filter.
*/
@java.lang.Override
public com.google.protobuf.ByteString getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PAGE_SIZE_FIELD_NUMBER = 3;
private int pageSize_ = 0;
/**
*
*
* <pre>
* The standard list page size.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
public static final int PAGE_TOKEN_FIELD_NUMBER = 4;
@SuppressWarnings("serial")
private volatile java.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* The standard list page token.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The pageToken.
*/
@java.lang.Override
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
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();
pageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* The standard list page token.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The bytes for pageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, filter_);
}
if (pageSize_ != 0) {
output.writeInt32(3, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, pageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, filter_);
}
if (pageSize_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, pageToken_);
}
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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest)) {
return super.equals(obj);
}
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest other =
(com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest) obj;
if (!getParent().equals(other.getParent())) return false;
if (!getFilter().equals(other.getFilter())) return false;
if (getPageSize() != other.getPageSize()) return false;
if (!getPageToken().equals(other.getPageToken())) 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();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
hash = (37 * hash) + FILTER_FIELD_NUMBER;
hash = (53 * hash) + getFilter().hashCode();
hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER;
hash = (53 * hash) + getPageSize();
hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
parseFrom(com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
parseFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest 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;
}
/**
*
*
* <pre>
* Request message for
* [EnterpriseKnowledgeGraphService.ListEntityReconciliationJobs][google.cloud.enterpriseknowledgegraph.v1.EnterpriseKnowledgeGraphService.ListEntityReconciliationJobs].
* </pre>
*
* Protobuf type {@code
* google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest)
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.enterpriseknowledgegraph.v1.ServiceProto
.internal_static_google_cloud_enterpriseknowledgegraph_v1_ListEntityReconciliationJobsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.enterpriseknowledgegraph.v1.ServiceProto
.internal_static_google_cloud_enterpriseknowledgegraph_v1_ListEntityReconciliationJobsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
.class,
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
.Builder.class);
}
// Construct using
// com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
parent_ = "";
filter_ = "";
pageSize_ = 0;
pageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.enterpriseknowledgegraph.v1.ServiceProto
.internal_static_google_cloud_enterpriseknowledgegraph_v1_ListEntityReconciliationJobsRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
getDefaultInstanceForType() {
return com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
build() {
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest result =
buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
buildPartial() {
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest result =
new com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest(
this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.parent_ = parent_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.filter_ = filter_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.pageSize_ = pageSize_;
}
if (((from_bitField0_ & 0x00000008) != 0)) {
result.pageToken_ = pageToken_;
}
}
@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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest) {
return mergeFrom(
(com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest)
other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest other) {
if (other
== com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
.getDefaultInstance()) return this;
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getFilter().isEmpty()) {
filter_ = other.filter_;
bitField0_ |= 0x00000002;
onChanged();
}
if (other.getPageSize() != 0) {
setPageSize(other.getPageSize());
}
if (!other.getPageToken().isEmpty()) {
pageToken_ = other.pageToken_;
bitField0_ |= 0x00000008;
onChanged();
}
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 10:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
filter_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 24:
{
pageSize_ = input.readInt32();
bitField0_ |= 0x00000004;
break;
} // case 24
case 34:
{
pageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000008;
break;
} // case 34
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.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The name of the EntityReconciliationJob's parent resource.
* Format: `projects/{project}/locations/{location}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The name of the EntityReconciliationJob's parent resource.
* Format: `projects/{project}/locations/{location}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The name of the EntityReconciliationJob's parent resource.
* Format: `projects/{project}/locations/{location}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The name of the EntityReconciliationJob's parent resource.
* Format: `projects/{project}/locations/{location}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The name of the EntityReconciliationJob's parent resource.
* Format: `projects/{project}/locations/{location}`
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object filter_ = "";
/**
*
*
* <pre>
* An expression for filtering the results of the request. For field names
* both snake_case and camelCase are supported.
* </pre>
*
* <code>string filter = 2;</code>
*
* @return The filter.
*/
public java.lang.String getFilter() {
java.lang.Object ref = filter_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
filter_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* An expression for filtering the results of the request. For field names
* both snake_case and camelCase are supported.
* </pre>
*
* <code>string filter = 2;</code>
*
* @return The bytes for filter.
*/
public com.google.protobuf.ByteString getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* An expression for filtering the results of the request. For field names
* both snake_case and camelCase are supported.
* </pre>
*
* <code>string filter = 2;</code>
*
* @param value The filter to set.
* @return This builder for chaining.
*/
public Builder setFilter(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
filter_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* An expression for filtering the results of the request. For field names
* both snake_case and camelCase are supported.
* </pre>
*
* <code>string filter = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearFilter() {
filter_ = getDefaultInstance().getFilter();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* An expression for filtering the results of the request. For field names
* both snake_case and camelCase are supported.
* </pre>
*
* <code>string filter = 2;</code>
*
* @param value The bytes for filter to set.
* @return This builder for chaining.
*/
public Builder setFilterBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
filter_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private int pageSize_;
/**
*
*
* <pre>
* The standard list page size.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
/**
*
*
* <pre>
* The standard list page size.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @param value The pageSize to set.
* @return This builder for chaining.
*/
public Builder setPageSize(int value) {
pageSize_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* The standard list page size.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @return This builder for chaining.
*/
public Builder clearPageSize() {
bitField0_ = (bitField0_ & ~0x00000004);
pageSize_ = 0;
onChanged();
return this;
}
private java.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* The standard list page token.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The pageToken.
*/
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
pageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The standard list page token.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The bytes for pageToken.
*/
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The standard list page token.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @param value The pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
pageToken_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
/**
*
*
* <pre>
* The standard list page token.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return This builder for chaining.
*/
public Builder clearPageToken() {
pageToken_ = getDefaultInstance().getPageToken();
bitField0_ = (bitField0_ & ~0x00000008);
onChanged();
return this;
}
/**
*
*
* <pre>
* The standard list page token.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @param value The bytes for pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
pageToken_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
@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.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest)
private static final com.google.cloud.enterpriseknowledgegraph.v1
.ListEntityReconciliationJobsRequest
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE =
new com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest();
}
public static com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListEntityReconciliationJobsRequest> PARSER =
new com.google.protobuf.AbstractParser<ListEntityReconciliationJobsRequest>() {
@java.lang.Override
public ListEntityReconciliationJobsRequest 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<ListEntityReconciliationJobsRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListEntityReconciliationJobsRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.enterpriseknowledgegraph.v1.ListEntityReconciliationJobsRequest
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,276 | java-data-fusion/proto-google-cloud-data-fusion-v1beta1/src/main/java/com/google/cloud/datafusion/v1beta1/ListNamespacesResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/datafusion/v1beta1/v1beta1.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.datafusion.v1beta1;
/**
*
*
* <pre>
* List namespaces response.
* </pre>
*
* Protobuf type {@code google.cloud.datafusion.v1beta1.ListNamespacesResponse}
*/
public final class ListNamespacesResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.datafusion.v1beta1.ListNamespacesResponse)
ListNamespacesResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListNamespacesResponse.newBuilder() to construct.
private ListNamespacesResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListNamespacesResponse() {
namespaces_ = java.util.Collections.emptyList();
nextPageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListNamespacesResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.datafusion.v1beta1.V1Beta1
.internal_static_google_cloud_datafusion_v1beta1_ListNamespacesResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.datafusion.v1beta1.V1Beta1
.internal_static_google_cloud_datafusion_v1beta1_ListNamespacesResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse.class,
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse.Builder.class);
}
public static final int NAMESPACES_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.datafusion.v1beta1.Namespace> namespaces_;
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.datafusion.v1beta1.Namespace> getNamespacesList() {
return namespaces_;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.cloud.datafusion.v1beta1.NamespaceOrBuilder>
getNamespacesOrBuilderList() {
return namespaces_;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
@java.lang.Override
public int getNamespacesCount() {
return namespaces_.size();
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
@java.lang.Override
public com.google.cloud.datafusion.v1beta1.Namespace getNamespaces(int index) {
return namespaces_.get(index);
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
@java.lang.Override
public com.google.cloud.datafusion.v1beta1.NamespaceOrBuilder getNamespacesOrBuilder(int index) {
return namespaces_.get(index);
}
public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Token to retrieve the next page of results or empty if there are no more
* results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
@java.lang.Override
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
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();
nextPageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* Token to retrieve the next page of results or empty if there are no more
* results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 {
for (int i = 0; i < namespaces_.size(); i++) {
output.writeMessage(1, namespaces_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < namespaces_.size(); i++) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, namespaces_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_);
}
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.datafusion.v1beta1.ListNamespacesResponse)) {
return super.equals(obj);
}
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse other =
(com.google.cloud.datafusion.v1beta1.ListNamespacesResponse) obj;
if (!getNamespacesList().equals(other.getNamespacesList())) return false;
if (!getNextPageToken().equals(other.getNextPageToken())) 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 (getNamespacesCount() > 0) {
hash = (37 * hash) + NAMESPACES_FIELD_NUMBER;
hash = (53 * hash) + getNamespacesList().hashCode();
}
hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getNextPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse 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.datafusion.v1beta1.ListNamespacesResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse 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.datafusion.v1beta1.ListNamespacesResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse 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.datafusion.v1beta1.ListNamespacesResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse 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.datafusion.v1beta1.ListNamespacesResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse 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.datafusion.v1beta1.ListNamespacesResponse 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;
}
/**
*
*
* <pre>
* List namespaces response.
* </pre>
*
* Protobuf type {@code google.cloud.datafusion.v1beta1.ListNamespacesResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.datafusion.v1beta1.ListNamespacesResponse)
com.google.cloud.datafusion.v1beta1.ListNamespacesResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.datafusion.v1beta1.V1Beta1
.internal_static_google_cloud_datafusion_v1beta1_ListNamespacesResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.datafusion.v1beta1.V1Beta1
.internal_static_google_cloud_datafusion_v1beta1_ListNamespacesResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse.class,
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse.Builder.class);
}
// Construct using com.google.cloud.datafusion.v1beta1.ListNamespacesResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (namespacesBuilder_ == null) {
namespaces_ = java.util.Collections.emptyList();
} else {
namespaces_ = null;
namespacesBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
nextPageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.datafusion.v1beta1.V1Beta1
.internal_static_google_cloud_datafusion_v1beta1_ListNamespacesResponse_descriptor;
}
@java.lang.Override
public com.google.cloud.datafusion.v1beta1.ListNamespacesResponse getDefaultInstanceForType() {
return com.google.cloud.datafusion.v1beta1.ListNamespacesResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.datafusion.v1beta1.ListNamespacesResponse build() {
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.datafusion.v1beta1.ListNamespacesResponse buildPartial() {
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse result =
new com.google.cloud.datafusion.v1beta1.ListNamespacesResponse(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.datafusion.v1beta1.ListNamespacesResponse result) {
if (namespacesBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
namespaces_ = java.util.Collections.unmodifiableList(namespaces_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.namespaces_ = namespaces_;
} else {
result.namespaces_ = namespacesBuilder_.build();
}
}
private void buildPartial0(com.google.cloud.datafusion.v1beta1.ListNamespacesResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.nextPageToken_ = nextPageToken_;
}
}
@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.datafusion.v1beta1.ListNamespacesResponse) {
return mergeFrom((com.google.cloud.datafusion.v1beta1.ListNamespacesResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.datafusion.v1beta1.ListNamespacesResponse other) {
if (other == com.google.cloud.datafusion.v1beta1.ListNamespacesResponse.getDefaultInstance())
return this;
if (namespacesBuilder_ == null) {
if (!other.namespaces_.isEmpty()) {
if (namespaces_.isEmpty()) {
namespaces_ = other.namespaces_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureNamespacesIsMutable();
namespaces_.addAll(other.namespaces_);
}
onChanged();
}
} else {
if (!other.namespaces_.isEmpty()) {
if (namespacesBuilder_.isEmpty()) {
namespacesBuilder_.dispose();
namespacesBuilder_ = null;
namespaces_ = other.namespaces_;
bitField0_ = (bitField0_ & ~0x00000001);
namespacesBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getNamespacesFieldBuilder()
: null;
} else {
namespacesBuilder_.addAllMessages(other.namespaces_);
}
}
}
if (!other.getNextPageToken().isEmpty()) {
nextPageToken_ = other.nextPageToken_;
bitField0_ |= 0x00000002;
onChanged();
}
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 10:
{
com.google.cloud.datafusion.v1beta1.Namespace m =
input.readMessage(
com.google.cloud.datafusion.v1beta1.Namespace.parser(), extensionRegistry);
if (namespacesBuilder_ == null) {
ensureNamespacesIsMutable();
namespaces_.add(m);
} else {
namespacesBuilder_.addMessage(m);
}
break;
} // case 10
case 18:
{
nextPageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
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.datafusion.v1beta1.Namespace> namespaces_ =
java.util.Collections.emptyList();
private void ensureNamespacesIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
namespaces_ =
new java.util.ArrayList<com.google.cloud.datafusion.v1beta1.Namespace>(namespaces_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.datafusion.v1beta1.Namespace,
com.google.cloud.datafusion.v1beta1.Namespace.Builder,
com.google.cloud.datafusion.v1beta1.NamespaceOrBuilder>
namespacesBuilder_;
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public java.util.List<com.google.cloud.datafusion.v1beta1.Namespace> getNamespacesList() {
if (namespacesBuilder_ == null) {
return java.util.Collections.unmodifiableList(namespaces_);
} else {
return namespacesBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public int getNamespacesCount() {
if (namespacesBuilder_ == null) {
return namespaces_.size();
} else {
return namespacesBuilder_.getCount();
}
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public com.google.cloud.datafusion.v1beta1.Namespace getNamespaces(int index) {
if (namespacesBuilder_ == null) {
return namespaces_.get(index);
} else {
return namespacesBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder setNamespaces(int index, com.google.cloud.datafusion.v1beta1.Namespace value) {
if (namespacesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureNamespacesIsMutable();
namespaces_.set(index, value);
onChanged();
} else {
namespacesBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder setNamespaces(
int index, com.google.cloud.datafusion.v1beta1.Namespace.Builder builderForValue) {
if (namespacesBuilder_ == null) {
ensureNamespacesIsMutable();
namespaces_.set(index, builderForValue.build());
onChanged();
} else {
namespacesBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder addNamespaces(com.google.cloud.datafusion.v1beta1.Namespace value) {
if (namespacesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureNamespacesIsMutable();
namespaces_.add(value);
onChanged();
} else {
namespacesBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder addNamespaces(int index, com.google.cloud.datafusion.v1beta1.Namespace value) {
if (namespacesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureNamespacesIsMutable();
namespaces_.add(index, value);
onChanged();
} else {
namespacesBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder addNamespaces(
com.google.cloud.datafusion.v1beta1.Namespace.Builder builderForValue) {
if (namespacesBuilder_ == null) {
ensureNamespacesIsMutable();
namespaces_.add(builderForValue.build());
onChanged();
} else {
namespacesBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder addNamespaces(
int index, com.google.cloud.datafusion.v1beta1.Namespace.Builder builderForValue) {
if (namespacesBuilder_ == null) {
ensureNamespacesIsMutable();
namespaces_.add(index, builderForValue.build());
onChanged();
} else {
namespacesBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder addAllNamespaces(
java.lang.Iterable<? extends com.google.cloud.datafusion.v1beta1.Namespace> values) {
if (namespacesBuilder_ == null) {
ensureNamespacesIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, namespaces_);
onChanged();
} else {
namespacesBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder clearNamespaces() {
if (namespacesBuilder_ == null) {
namespaces_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
namespacesBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public Builder removeNamespaces(int index) {
if (namespacesBuilder_ == null) {
ensureNamespacesIsMutable();
namespaces_.remove(index);
onChanged();
} else {
namespacesBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public com.google.cloud.datafusion.v1beta1.Namespace.Builder getNamespacesBuilder(int index) {
return getNamespacesFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public com.google.cloud.datafusion.v1beta1.NamespaceOrBuilder getNamespacesOrBuilder(
int index) {
if (namespacesBuilder_ == null) {
return namespaces_.get(index);
} else {
return namespacesBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public java.util.List<? extends com.google.cloud.datafusion.v1beta1.NamespaceOrBuilder>
getNamespacesOrBuilderList() {
if (namespacesBuilder_ != null) {
return namespacesBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(namespaces_);
}
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public com.google.cloud.datafusion.v1beta1.Namespace.Builder addNamespacesBuilder() {
return getNamespacesFieldBuilder()
.addBuilder(com.google.cloud.datafusion.v1beta1.Namespace.getDefaultInstance());
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public com.google.cloud.datafusion.v1beta1.Namespace.Builder addNamespacesBuilder(int index) {
return getNamespacesFieldBuilder()
.addBuilder(index, com.google.cloud.datafusion.v1beta1.Namespace.getDefaultInstance());
}
/**
*
*
* <pre>
* List of namespaces
* </pre>
*
* <code>repeated .google.cloud.datafusion.v1beta1.Namespace namespaces = 1;</code>
*/
public java.util.List<com.google.cloud.datafusion.v1beta1.Namespace.Builder>
getNamespacesBuilderList() {
return getNamespacesFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.datafusion.v1beta1.Namespace,
com.google.cloud.datafusion.v1beta1.Namespace.Builder,
com.google.cloud.datafusion.v1beta1.NamespaceOrBuilder>
getNamespacesFieldBuilder() {
if (namespacesBuilder_ == null) {
namespacesBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.datafusion.v1beta1.Namespace,
com.google.cloud.datafusion.v1beta1.Namespace.Builder,
com.google.cloud.datafusion.v1beta1.NamespaceOrBuilder>(
namespaces_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
namespaces_ = null;
}
return namespacesBuilder_;
}
private java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Token to retrieve the next page of results or empty if there are no more
* results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
nextPageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Token to retrieve the next page of results or empty if there are no more
* results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Token to retrieve the next page of results or empty if there are no more
* results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Token to retrieve the next page of results or empty if there are no more
* results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearNextPageToken() {
nextPageToken_ = getDefaultInstance().getNextPageToken();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Token to retrieve the next page of results or empty if there are no more
* results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The bytes for nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.datafusion.v1beta1.ListNamespacesResponse)
}
// @@protoc_insertion_point(class_scope:google.cloud.datafusion.v1beta1.ListNamespacesResponse)
private static final com.google.cloud.datafusion.v1beta1.ListNamespacesResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.datafusion.v1beta1.ListNamespacesResponse();
}
public static com.google.cloud.datafusion.v1beta1.ListNamespacesResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListNamespacesResponse> PARSER =
new com.google.protobuf.AbstractParser<ListNamespacesResponse>() {
@java.lang.Override
public ListNamespacesResponse 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<ListNamespacesResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListNamespacesResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.datafusion.v1beta1.ListNamespacesResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,309 | java-dialogflow-cx/proto-google-cloud-dialogflow-cx-v3beta1/src/main/java/com/google/cloud/dialogflow/cx/v3beta1/ExportToolsResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/dialogflow/cx/v3beta1/tool.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.dialogflow.cx.v3beta1;
/**
*
*
* <pre>
* The response message for
* [Tools.ExportTools][google.cloud.dialogflow.cx.v3beta1.Tools.ExportTools].
* </pre>
*
* Protobuf type {@code google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse}
*/
public final class ExportToolsResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse)
ExportToolsResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ExportToolsResponse.newBuilder() to construct.
private ExportToolsResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ExportToolsResponse() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ExportToolsResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.dialogflow.cx.v3beta1.ToolProto
.internal_static_google_cloud_dialogflow_cx_v3beta1_ExportToolsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.dialogflow.cx.v3beta1.ToolProto
.internal_static_google_cloud_dialogflow_cx_v3beta1_ExportToolsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse.class,
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse.Builder.class);
}
private int toolsCase_ = 0;
@SuppressWarnings("serial")
private java.lang.Object tools_;
public enum ToolsCase
implements
com.google.protobuf.Internal.EnumLite,
com.google.protobuf.AbstractMessage.InternalOneOfEnum {
TOOLS_URI(1),
TOOLS_CONTENT(2),
TOOLS_NOT_SET(0);
private final int value;
private ToolsCase(int value) {
this.value = value;
}
/**
* @param value The number of the enum to look for.
* @return The enum associated with the given number.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static ToolsCase valueOf(int value) {
return forNumber(value);
}
public static ToolsCase forNumber(int value) {
switch (value) {
case 1:
return TOOLS_URI;
case 2:
return TOOLS_CONTENT;
case 0:
return TOOLS_NOT_SET;
default:
return null;
}
}
public int getNumber() {
return this.value;
}
};
public ToolsCase getToolsCase() {
return ToolsCase.forNumber(toolsCase_);
}
public static final int TOOLS_URI_FIELD_NUMBER = 1;
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @return Whether the toolsUri field is set.
*/
public boolean hasToolsUri() {
return toolsCase_ == 1;
}
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @return The toolsUri.
*/
public java.lang.String getToolsUri() {
java.lang.Object ref = "";
if (toolsCase_ == 1) {
ref = tools_;
}
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();
if (toolsCase_ == 1) {
tools_ = s;
}
return s;
}
}
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @return The bytes for toolsUri.
*/
public com.google.protobuf.ByteString getToolsUriBytes() {
java.lang.Object ref = "";
if (toolsCase_ == 1) {
ref = tools_;
}
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
if (toolsCase_ == 1) {
tools_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int TOOLS_CONTENT_FIELD_NUMBER = 2;
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*
* @return Whether the toolsContent field is set.
*/
@java.lang.Override
public boolean hasToolsContent() {
return toolsCase_ == 2;
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*
* @return The toolsContent.
*/
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.InlineDestination getToolsContent() {
if (toolsCase_ == 2) {
return (com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_;
}
return com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.getDefaultInstance();
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.InlineDestinationOrBuilder
getToolsContentOrBuilder() {
if (toolsCase_ == 2) {
return (com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_;
}
return com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.getDefaultInstance();
}
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 (toolsCase_ == 1) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tools_);
}
if (toolsCase_ == 2) {
output.writeMessage(2, (com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (toolsCase_ == 1) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tools_);
}
if (toolsCase_ == 2) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
2, (com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_);
}
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.dialogflow.cx.v3beta1.ExportToolsResponse)) {
return super.equals(obj);
}
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse other =
(com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse) obj;
if (!getToolsCase().equals(other.getToolsCase())) return false;
switch (toolsCase_) {
case 1:
if (!getToolsUri().equals(other.getToolsUri())) return false;
break;
case 2:
if (!getToolsContent().equals(other.getToolsContent())) return false;
break;
case 0:
default:
}
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();
switch (toolsCase_) {
case 1:
hash = (37 * hash) + TOOLS_URI_FIELD_NUMBER;
hash = (53 * hash) + getToolsUri().hashCode();
break;
case 2:
hash = (37 * hash) + TOOLS_CONTENT_FIELD_NUMBER;
hash = (53 * hash) + getToolsContent().hashCode();
break;
case 0:
default:
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse 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.dialogflow.cx.v3beta1.ExportToolsResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse 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.dialogflow.cx.v3beta1.ExportToolsResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse 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.dialogflow.cx.v3beta1.ExportToolsResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse 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.dialogflow.cx.v3beta1.ExportToolsResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse 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.dialogflow.cx.v3beta1.ExportToolsResponse 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;
}
/**
*
*
* <pre>
* The response message for
* [Tools.ExportTools][google.cloud.dialogflow.cx.v3beta1.Tools.ExportTools].
* </pre>
*
* Protobuf type {@code google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse)
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.dialogflow.cx.v3beta1.ToolProto
.internal_static_google_cloud_dialogflow_cx_v3beta1_ExportToolsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.dialogflow.cx.v3beta1.ToolProto
.internal_static_google_cloud_dialogflow_cx_v3beta1_ExportToolsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse.class,
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse.Builder.class);
}
// Construct using com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (toolsContentBuilder_ != null) {
toolsContentBuilder_.clear();
}
toolsCase_ = 0;
tools_ = null;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.dialogflow.cx.v3beta1.ToolProto
.internal_static_google_cloud_dialogflow_cx_v3beta1_ExportToolsResponse_descriptor;
}
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse getDefaultInstanceForType() {
return com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse build() {
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse buildPartial() {
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse result =
new com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
buildPartialOneofs(result);
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse result) {
int from_bitField0_ = bitField0_;
}
private void buildPartialOneofs(
com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse result) {
result.toolsCase_ = toolsCase_;
result.tools_ = this.tools_;
if (toolsCase_ == 2 && toolsContentBuilder_ != null) {
result.tools_ = toolsContentBuilder_.build();
}
}
@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.dialogflow.cx.v3beta1.ExportToolsResponse) {
return mergeFrom((com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse other) {
if (other == com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse.getDefaultInstance())
return this;
switch (other.getToolsCase()) {
case TOOLS_URI:
{
toolsCase_ = 1;
tools_ = other.tools_;
onChanged();
break;
}
case TOOLS_CONTENT:
{
mergeToolsContent(other.getToolsContent());
break;
}
case TOOLS_NOT_SET:
{
break;
}
}
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 10:
{
java.lang.String s = input.readStringRequireUtf8();
toolsCase_ = 1;
tools_ = s;
break;
} // case 10
case 18:
{
input.readMessage(getToolsContentFieldBuilder().getBuilder(), extensionRegistry);
toolsCase_ = 2;
break;
} // case 18
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 toolsCase_ = 0;
private java.lang.Object tools_;
public ToolsCase getToolsCase() {
return ToolsCase.forNumber(toolsCase_);
}
public Builder clearTools() {
toolsCase_ = 0;
tools_ = null;
onChanged();
return this;
}
private int bitField0_;
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @return Whether the toolsUri field is set.
*/
@java.lang.Override
public boolean hasToolsUri() {
return toolsCase_ == 1;
}
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @return The toolsUri.
*/
@java.lang.Override
public java.lang.String getToolsUri() {
java.lang.Object ref = "";
if (toolsCase_ == 1) {
ref = tools_;
}
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (toolsCase_ == 1) {
tools_ = s;
}
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @return The bytes for toolsUri.
*/
@java.lang.Override
public com.google.protobuf.ByteString getToolsUriBytes() {
java.lang.Object ref = "";
if (toolsCase_ == 1) {
ref = tools_;
}
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
if (toolsCase_ == 1) {
tools_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @param value The toolsUri to set.
* @return This builder for chaining.
*/
public Builder setToolsUri(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
toolsCase_ = 1;
tools_ = value;
onChanged();
return this;
}
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @return This builder for chaining.
*/
public Builder clearToolsUri() {
if (toolsCase_ == 1) {
toolsCase_ = 0;
tools_ = null;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* The URI to a file containing the exported tools. This field is
* populated only if `tools_uri` is specified in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>string tools_uri = 1;</code>
*
* @param value The bytes for toolsUri to set.
* @return This builder for chaining.
*/
public Builder setToolsUriBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
toolsCase_ = 1;
tools_ = value;
onChanged();
return this;
}
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination,
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.Builder,
com.google.cloud.dialogflow.cx.v3beta1.InlineDestinationOrBuilder>
toolsContentBuilder_;
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*
* @return Whether the toolsContent field is set.
*/
@java.lang.Override
public boolean hasToolsContent() {
return toolsCase_ == 2;
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*
* @return The toolsContent.
*/
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.InlineDestination getToolsContent() {
if (toolsContentBuilder_ == null) {
if (toolsCase_ == 2) {
return (com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_;
}
return com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.getDefaultInstance();
} else {
if (toolsCase_ == 2) {
return toolsContentBuilder_.getMessage();
}
return com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.getDefaultInstance();
}
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
public Builder setToolsContent(com.google.cloud.dialogflow.cx.v3beta1.InlineDestination value) {
if (toolsContentBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
tools_ = value;
onChanged();
} else {
toolsContentBuilder_.setMessage(value);
}
toolsCase_ = 2;
return this;
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
public Builder setToolsContent(
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.Builder builderForValue) {
if (toolsContentBuilder_ == null) {
tools_ = builderForValue.build();
onChanged();
} else {
toolsContentBuilder_.setMessage(builderForValue.build());
}
toolsCase_ = 2;
return this;
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
public Builder mergeToolsContent(
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination value) {
if (toolsContentBuilder_ == null) {
if (toolsCase_ == 2
&& tools_
!= com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.getDefaultInstance()) {
tools_ =
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.newBuilder(
(com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_)
.mergeFrom(value)
.buildPartial();
} else {
tools_ = value;
}
onChanged();
} else {
if (toolsCase_ == 2) {
toolsContentBuilder_.mergeFrom(value);
} else {
toolsContentBuilder_.setMessage(value);
}
}
toolsCase_ = 2;
return this;
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
public Builder clearToolsContent() {
if (toolsContentBuilder_ == null) {
if (toolsCase_ == 2) {
toolsCase_ = 0;
tools_ = null;
onChanged();
}
} else {
if (toolsCase_ == 2) {
toolsCase_ = 0;
tools_ = null;
}
toolsContentBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
public com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.Builder
getToolsContentBuilder() {
return getToolsContentFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.InlineDestinationOrBuilder
getToolsContentOrBuilder() {
if ((toolsCase_ == 2) && (toolsContentBuilder_ != null)) {
return toolsContentBuilder_.getMessageOrBuilder();
} else {
if (toolsCase_ == 2) {
return (com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_;
}
return com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.getDefaultInstance();
}
}
/**
*
*
* <pre>
* Uncompressed byte content for tools. This field is populated only if
* `tools_content_inline` is set to true in
* [ExportToolsRequest][google.cloud.dialogflow.cx.v3beta1.ExportToolsRequest].
* </pre>
*
* <code>.google.cloud.dialogflow.cx.v3beta1.InlineDestination tools_content = 2;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination,
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.Builder,
com.google.cloud.dialogflow.cx.v3beta1.InlineDestinationOrBuilder>
getToolsContentFieldBuilder() {
if (toolsContentBuilder_ == null) {
if (!(toolsCase_ == 2)) {
tools_ = com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.getDefaultInstance();
}
toolsContentBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination,
com.google.cloud.dialogflow.cx.v3beta1.InlineDestination.Builder,
com.google.cloud.dialogflow.cx.v3beta1.InlineDestinationOrBuilder>(
(com.google.cloud.dialogflow.cx.v3beta1.InlineDestination) tools_,
getParentForChildren(),
isClean());
tools_ = null;
}
toolsCase_ = 2;
onChanged();
return toolsContentBuilder_;
}
@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.dialogflow.cx.v3beta1.ExportToolsResponse)
}
// @@protoc_insertion_point(class_scope:google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse)
private static final com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse();
}
public static com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ExportToolsResponse> PARSER =
new com.google.protobuf.AbstractParser<ExportToolsResponse>() {
@java.lang.Override
public ExportToolsResponse 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<ExportToolsResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ExportToolsResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.dialogflow.cx.v3beta1.ExportToolsResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,283 | java-geminidataanalytics/proto-google-cloud-geminidataanalytics-v1beta/src/main/java/com/google/cloud/geminidataanalytics/v1beta/AnalysisMessage.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/geminidataanalytics/v1beta/data_chat_service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.geminidataanalytics.v1beta;
/**
*
*
* <pre>
* A message produced during analysis.
* </pre>
*
* Protobuf type {@code google.cloud.geminidataanalytics.v1beta.AnalysisMessage}
*/
public final class AnalysisMessage extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.geminidataanalytics.v1beta.AnalysisMessage)
AnalysisMessageOrBuilder {
private static final long serialVersionUID = 0L;
// Use AnalysisMessage.newBuilder() to construct.
private AnalysisMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private AnalysisMessage() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new AnalysisMessage();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.geminidataanalytics.v1beta.DataChatServiceProto
.internal_static_google_cloud_geminidataanalytics_v1beta_AnalysisMessage_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.geminidataanalytics.v1beta.DataChatServiceProto
.internal_static_google_cloud_geminidataanalytics_v1beta_AnalysisMessage_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage.class,
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage.Builder.class);
}
private int kindCase_ = 0;
@SuppressWarnings("serial")
private java.lang.Object kind_;
public enum KindCase
implements
com.google.protobuf.Internal.EnumLite,
com.google.protobuf.AbstractMessage.InternalOneOfEnum {
QUERY(1),
PROGRESS_EVENT(2),
KIND_NOT_SET(0);
private final int value;
private KindCase(int value) {
this.value = value;
}
/**
* @param value The number of the enum to look for.
* @return The enum associated with the given number.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static KindCase valueOf(int value) {
return forNumber(value);
}
public static KindCase forNumber(int value) {
switch (value) {
case 1:
return QUERY;
case 2:
return PROGRESS_EVENT;
case 0:
return KIND_NOT_SET;
default:
return null;
}
}
public int getNumber() {
return this.value;
}
};
public KindCase getKindCase() {
return KindCase.forNumber(kindCase_);
}
public static final int QUERY_FIELD_NUMBER = 1;
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*
* @return Whether the query field is set.
*/
@java.lang.Override
public boolean hasQuery() {
return kindCase_ == 1;
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*
* @return The query.
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery getQuery() {
if (kindCase_ == 1) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.getDefaultInstance();
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisQueryOrBuilder getQueryOrBuilder() {
if (kindCase_ == 1) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.getDefaultInstance();
}
public static final int PROGRESS_EVENT_FIELD_NUMBER = 2;
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*
* @return Whether the progressEvent field is set.
*/
@java.lang.Override
public boolean hasProgressEvent() {
return kindCase_ == 2;
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*
* @return The progressEvent.
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent getProgressEvent() {
if (kindCase_ == 2) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.getDefaultInstance();
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisEventOrBuilder
getProgressEventOrBuilder() {
if (kindCase_ == 2) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.getDefaultInstance();
}
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 (kindCase_ == 1) {
output.writeMessage(1, (com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_);
}
if (kindCase_ == 2) {
output.writeMessage(2, (com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (kindCase_ == 1) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
1, (com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_);
}
if (kindCase_ == 2) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
2, (com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_);
}
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.geminidataanalytics.v1beta.AnalysisMessage)) {
return super.equals(obj);
}
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage other =
(com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage) obj;
if (!getKindCase().equals(other.getKindCase())) return false;
switch (kindCase_) {
case 1:
if (!getQuery().equals(other.getQuery())) return false;
break;
case 2:
if (!getProgressEvent().equals(other.getProgressEvent())) return false;
break;
case 0:
default:
}
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();
switch (kindCase_) {
case 1:
hash = (37 * hash) + QUERY_FIELD_NUMBER;
hash = (53 * hash) + getQuery().hashCode();
break;
case 2:
hash = (37 * hash) + PROGRESS_EVENT_FIELD_NUMBER;
hash = (53 * hash) + getProgressEvent().hashCode();
break;
case 0:
default:
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage 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.geminidataanalytics.v1beta.AnalysisMessage parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage 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.geminidataanalytics.v1beta.AnalysisMessage parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage 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.geminidataanalytics.v1beta.AnalysisMessage parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage 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.geminidataanalytics.v1beta.AnalysisMessage parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage 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.geminidataanalytics.v1beta.AnalysisMessage 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;
}
/**
*
*
* <pre>
* A message produced during analysis.
* </pre>
*
* Protobuf type {@code google.cloud.geminidataanalytics.v1beta.AnalysisMessage}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.geminidataanalytics.v1beta.AnalysisMessage)
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessageOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.geminidataanalytics.v1beta.DataChatServiceProto
.internal_static_google_cloud_geminidataanalytics_v1beta_AnalysisMessage_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.geminidataanalytics.v1beta.DataChatServiceProto
.internal_static_google_cloud_geminidataanalytics_v1beta_AnalysisMessage_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage.class,
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage.Builder.class);
}
// Construct using com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (queryBuilder_ != null) {
queryBuilder_.clear();
}
if (progressEventBuilder_ != null) {
progressEventBuilder_.clear();
}
kindCase_ = 0;
kind_ = null;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.geminidataanalytics.v1beta.DataChatServiceProto
.internal_static_google_cloud_geminidataanalytics_v1beta_AnalysisMessage_descriptor;
}
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage getDefaultInstanceForType() {
return com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage build() {
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage buildPartial() {
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage result =
new com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
buildPartialOneofs(result);
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage result) {
int from_bitField0_ = bitField0_;
}
private void buildPartialOneofs(
com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage result) {
result.kindCase_ = kindCase_;
result.kind_ = this.kind_;
if (kindCase_ == 1 && queryBuilder_ != null) {
result.kind_ = queryBuilder_.build();
}
if (kindCase_ == 2 && progressEventBuilder_ != null) {
result.kind_ = progressEventBuilder_.build();
}
}
@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.geminidataanalytics.v1beta.AnalysisMessage) {
return mergeFrom((com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage other) {
if (other == com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage.getDefaultInstance())
return this;
switch (other.getKindCase()) {
case QUERY:
{
mergeQuery(other.getQuery());
break;
}
case PROGRESS_EVENT:
{
mergeProgressEvent(other.getProgressEvent());
break;
}
case KIND_NOT_SET:
{
break;
}
}
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 10:
{
input.readMessage(getQueryFieldBuilder().getBuilder(), extensionRegistry);
kindCase_ = 1;
break;
} // case 10
case 18:
{
input.readMessage(getProgressEventFieldBuilder().getBuilder(), extensionRegistry);
kindCase_ = 2;
break;
} // case 18
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 kindCase_ = 0;
private java.lang.Object kind_;
public KindCase getKindCase() {
return KindCase.forNumber(kindCase_);
}
public Builder clearKind() {
kindCase_ = 0;
kind_ = null;
onChanged();
return this;
}
private int bitField0_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery,
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.Builder,
com.google.cloud.geminidataanalytics.v1beta.AnalysisQueryOrBuilder>
queryBuilder_;
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*
* @return Whether the query field is set.
*/
@java.lang.Override
public boolean hasQuery() {
return kindCase_ == 1;
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*
* @return The query.
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery getQuery() {
if (queryBuilder_ == null) {
if (kindCase_ == 1) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.getDefaultInstance();
} else {
if (kindCase_ == 1) {
return queryBuilder_.getMessage();
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.getDefaultInstance();
}
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
public Builder setQuery(com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery value) {
if (queryBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
kind_ = value;
onChanged();
} else {
queryBuilder_.setMessage(value);
}
kindCase_ = 1;
return this;
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
public Builder setQuery(
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.Builder builderForValue) {
if (queryBuilder_ == null) {
kind_ = builderForValue.build();
onChanged();
} else {
queryBuilder_.setMessage(builderForValue.build());
}
kindCase_ = 1;
return this;
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
public Builder mergeQuery(com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery value) {
if (queryBuilder_ == null) {
if (kindCase_ == 1
&& kind_
!= com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.getDefaultInstance()) {
kind_ =
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.newBuilder(
(com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_)
.mergeFrom(value)
.buildPartial();
} else {
kind_ = value;
}
onChanged();
} else {
if (kindCase_ == 1) {
queryBuilder_.mergeFrom(value);
} else {
queryBuilder_.setMessage(value);
}
}
kindCase_ = 1;
return this;
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
public Builder clearQuery() {
if (queryBuilder_ == null) {
if (kindCase_ == 1) {
kindCase_ = 0;
kind_ = null;
onChanged();
}
} else {
if (kindCase_ == 1) {
kindCase_ = 0;
kind_ = null;
}
queryBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
public com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.Builder getQueryBuilder() {
return getQueryFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisQueryOrBuilder getQueryOrBuilder() {
if ((kindCase_ == 1) && (queryBuilder_ != null)) {
return queryBuilder_.getMessageOrBuilder();
} else {
if (kindCase_ == 1) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.getDefaultInstance();
}
}
/**
*
*
* <pre>
* An analysis query.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisQuery query = 1;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery,
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.Builder,
com.google.cloud.geminidataanalytics.v1beta.AnalysisQueryOrBuilder>
getQueryFieldBuilder() {
if (queryBuilder_ == null) {
if (!(kindCase_ == 1)) {
kind_ = com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.getDefaultInstance();
}
queryBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery,
com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery.Builder,
com.google.cloud.geminidataanalytics.v1beta.AnalysisQueryOrBuilder>(
(com.google.cloud.geminidataanalytics.v1beta.AnalysisQuery) kind_,
getParentForChildren(),
isClean());
kind_ = null;
}
kindCase_ = 1;
onChanged();
return queryBuilder_;
}
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent,
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.Builder,
com.google.cloud.geminidataanalytics.v1beta.AnalysisEventOrBuilder>
progressEventBuilder_;
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*
* @return Whether the progressEvent field is set.
*/
@java.lang.Override
public boolean hasProgressEvent() {
return kindCase_ == 2;
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*
* @return The progressEvent.
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent getProgressEvent() {
if (progressEventBuilder_ == null) {
if (kindCase_ == 2) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.getDefaultInstance();
} else {
if (kindCase_ == 2) {
return progressEventBuilder_.getMessage();
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.getDefaultInstance();
}
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
public Builder setProgressEvent(
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent value) {
if (progressEventBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
kind_ = value;
onChanged();
} else {
progressEventBuilder_.setMessage(value);
}
kindCase_ = 2;
return this;
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
public Builder setProgressEvent(
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.Builder builderForValue) {
if (progressEventBuilder_ == null) {
kind_ = builderForValue.build();
onChanged();
} else {
progressEventBuilder_.setMessage(builderForValue.build());
}
kindCase_ = 2;
return this;
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
public Builder mergeProgressEvent(
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent value) {
if (progressEventBuilder_ == null) {
if (kindCase_ == 2
&& kind_
!= com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.getDefaultInstance()) {
kind_ =
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.newBuilder(
(com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_)
.mergeFrom(value)
.buildPartial();
} else {
kind_ = value;
}
onChanged();
} else {
if (kindCase_ == 2) {
progressEventBuilder_.mergeFrom(value);
} else {
progressEventBuilder_.setMessage(value);
}
}
kindCase_ = 2;
return this;
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
public Builder clearProgressEvent() {
if (progressEventBuilder_ == null) {
if (kindCase_ == 2) {
kindCase_ = 0;
kind_ = null;
onChanged();
}
} else {
if (kindCase_ == 2) {
kindCase_ = 0;
kind_ = null;
}
progressEventBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
public com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.Builder
getProgressEventBuilder() {
return getProgressEventFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisEventOrBuilder
getProgressEventOrBuilder() {
if ((kindCase_ == 2) && (progressEventBuilder_ != null)) {
return progressEventBuilder_.getMessageOrBuilder();
} else {
if (kindCase_ == 2) {
return (com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_;
}
return com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.getDefaultInstance();
}
}
/**
*
*
* <pre>
* An event indicating the progress of the analysis.
* </pre>
*
* <code>.google.cloud.geminidataanalytics.v1beta.AnalysisEvent progress_event = 2;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent,
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.Builder,
com.google.cloud.geminidataanalytics.v1beta.AnalysisEventOrBuilder>
getProgressEventFieldBuilder() {
if (progressEventBuilder_ == null) {
if (!(kindCase_ == 2)) {
kind_ = com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.getDefaultInstance();
}
progressEventBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent,
com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent.Builder,
com.google.cloud.geminidataanalytics.v1beta.AnalysisEventOrBuilder>(
(com.google.cloud.geminidataanalytics.v1beta.AnalysisEvent) kind_,
getParentForChildren(),
isClean());
kind_ = null;
}
kindCase_ = 2;
onChanged();
return progressEventBuilder_;
}
@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.geminidataanalytics.v1beta.AnalysisMessage)
}
// @@protoc_insertion_point(class_scope:google.cloud.geminidataanalytics.v1beta.AnalysisMessage)
private static final com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage();
}
public static com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<AnalysisMessage> PARSER =
new com.google.protobuf.AbstractParser<AnalysisMessage>() {
@java.lang.Override
public AnalysisMessage 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<AnalysisMessage> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<AnalysisMessage> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.geminidataanalytics.v1beta.AnalysisMessage getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/httpcomponents-client | 36,404 | httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java | /*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.testing.sync;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Collections;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.apache.hc.client5.http.ClientProtocolException;
import org.apache.hc.client5.http.auth.AuthCache;
import org.apache.hc.client5.http.auth.AuthScheme;
import org.apache.hc.client5.http.auth.AuthSchemeFactory;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.BearerToken;
import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.auth.StandardAuthScheme;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.classic.methods.HttpPut;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy;
import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
import org.apache.hc.client5.http.impl.auth.BasicScheme;
import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.testing.BasicTestAuthenticator;
import org.apache.hc.client5.testing.auth.Authenticator;
import org.apache.hc.client5.testing.auth.BearerAuthenticationHandler;
import org.apache.hc.client5.testing.classic.AuthenticatingDecorator;
import org.apache.hc.client5.testing.classic.EchoHandler;
import org.apache.hc.client5.testing.extension.sync.ClientProtocolLevel;
import org.apache.hc.client5.testing.extension.sync.TestClient;
import org.apache.hc.client5.testing.extension.sync.TestServerBootstrap;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HeaderElements;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.io.HttpRequestHandler;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.InputStreamEntity;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.support.BasicResponseBuilder;
import org.apache.hc.core5.net.URIAuthority;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
/**
* Unit tests for automatic client authentication.
*/
abstract class TestClientAuthentication extends AbstractIntegrationTestBase {
protected TestClientAuthentication(final URIScheme scheme) {
super(scheme, ClientProtocolLevel.STANDARD);
}
public void configureServerWithBasicAuth(final Authenticator authenticator,
final Consumer<TestServerBootstrap> serverCustomizer) {
configureServer(bootstrap -> {
bootstrap.setExchangeHandlerDecorator(requestHandler ->
new AuthenticatingDecorator(requestHandler, authenticator));
serverCustomizer.accept(bootstrap);
});
}
public void configureServerWithBasicAuth(final Consumer<TestServerBootstrap> serverCustomizer) {
configureServerWithBasicAuth(
new BasicTestAuthenticator("test:test", "test realm"),
serverCustomizer);
}
@Test
void testBasicAuthenticationNoCreds() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
context.setCredentialsProvider(credsProvider);
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
Mockito.verify(credsProvider).getCredentials(
Mockito.eq(new AuthScope(target, "test realm", "basic")), Mockito.any());
}
@Test
void testBasicAuthenticationFailure() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "all-wrong".toCharArray()));
context.setCredentialsProvider(credsProvider);
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
Mockito.verify(credsProvider).getCredentials(
Mockito.eq(new AuthScope(target, "test realm", "basic")), Mockito.any());
}
@Test
void testBasicAuthenticationSuccess() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpGet httpget = new HttpGet("/");
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "test".toCharArray()));
context.setCredentialsProvider(credsProvider);
client.execute(target, httpget, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
Mockito.verify(credsProvider).getCredentials(
Mockito.eq(new AuthScope(target, "test realm", "basic")), Mockito.any());
}
@Test
void testBasicAuthenticationSuccessOnNonRepeatablePutExpectContinue() throws Exception {
configureServer(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final RequestConfig config = RequestConfig.custom()
.setExpectContinueEnabled(true)
.build();
final HttpPut httpput = new HttpPut("/");
httpput.setConfig(config);
httpput.setEntity(new InputStreamEntity(
new ByteArrayInputStream(
new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9}),
-1, null));
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "test".toCharArray()));
context.setCredentialsProvider(credsProvider);
client.execute(target, httpput, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity);
return null;
});
}
@Test
void testBasicAuthenticationFailureOnNonRepeatablePutDontExpectContinue() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(false).build();
final HttpPut httpput = new HttpPut("/");
httpput.setConfig(config);
httpput.setEntity(new InputStreamEntity(
new ByteArrayInputStream(
new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9}),
-1, null));
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "boom".toCharArray()));
context.setCredentialsProvider(credsProvider);
client.execute(target, httpput, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(401, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
}
@Test
void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpPost httppost = new HttpPost("/");
httppost.setEntity(new StringEntity("some important stuff", StandardCharsets.US_ASCII));
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "test".toCharArray()));
context.setCredentialsProvider(credsProvider);
client.execute(target, httppost, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
Mockito.verify(credsProvider).getCredentials(
Mockito.eq(new AuthScope(target, "test realm", "basic")), Mockito.any());
}
@Test
void testBasicAuthenticationFailureOnNonRepeatablePost() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpPost httppost = new HttpPost("/");
httppost.setEntity(new InputStreamEntity(
new ByteArrayInputStream(
new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}), -1, null));
final HttpClientContext context = HttpClientContext.create();
context.setRequestConfig(RequestConfig.custom()
.setExpectContinueEnabled(false)
.build());
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "test".toCharArray()));
context.setCredentialsProvider(credsProvider);
client.execute(target, httppost, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(401, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
}
@Test
void testBasicAuthenticationCredentialsCaching() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final DefaultAuthenticationStrategy authStrategy = Mockito.spy(new DefaultAuthenticationStrategy());
final Queue<HttpResponse> responseQueue = new ConcurrentLinkedQueue<>();
configureClient(builder -> builder
.setTargetAuthenticationStrategy(authStrategy)
.addResponseInterceptorLast((response, entity, context)
-> responseQueue.add(BasicResponseBuilder.copy(response).build())));
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(CredentialsProviderBuilder.create()
.add(target, "test", "test".toCharArray())
.build());
for (int i = 0; i < 5; i++) {
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
final HttpEntity entity1 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity1);
EntityUtils.consume(entity1);
return null;
});
}
Mockito.verify(authStrategy).select(Mockito.any(), Mockito.any(), Mockito.any());
assertThat(
responseQueue.stream().map(HttpResponse::getCode).collect(Collectors.toList()),
CoreMatchers.equalTo(Arrays.asList(401, 200, 200, 200, 200, 200)));
}
@Test
void testBasicAuthenticationCredentialsCachingByPathPrefix() throws Exception {
configureServerWithBasicAuth(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final DefaultAuthenticationStrategy authStrategy = Mockito.spy(new DefaultAuthenticationStrategy());
final Queue<HttpResponse> responseQueue = new ConcurrentLinkedQueue<>();
configureClient(builder -> builder
.setTargetAuthenticationStrategy(authStrategy)
.addResponseInterceptorLast((response, entity, context)
-> responseQueue.add(BasicResponseBuilder.copy(response).build())));
final TestClient client = client();
final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create()
.add(target, "test", "test".toCharArray())
.build();
final AuthCache authCache = new BasicAuthCache();
final HttpClientContext context = HttpClientContext.create();
context.setAuthCache(authCache);
context.setCredentialsProvider(credentialsProvider);
for (final String requestPath : new String[]{"/blah/a", "/blah/b?huh", "/blah/c", "/bl%61h/%61"}) {
final HttpGet httpget = new HttpGet(requestPath);
client.execute(target, httpget, context, response -> {
final HttpEntity entity1 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity1);
EntityUtils.consume(entity1);
return null;
});
}
// There should be only single auth strategy call for all successful message exchanges
Mockito.verify(authStrategy).select(Mockito.any(), Mockito.any(), Mockito.any());
assertThat(
responseQueue.stream().map(HttpResponse::getCode).collect(Collectors.toList()),
CoreMatchers.equalTo(Arrays.asList(401, 200, 200, 200, 200)));
responseQueue.clear();
authCache.clear();
Mockito.reset(authStrategy);
for (final String requestPath : new String[]{"/blah/a", "/yada/a", "/blah/blah/", "/buh/a"}) {
final HttpGet httpget = new HttpGet(requestPath);
client.execute(target, httpget, context, response -> {
final HttpEntity entity1 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity1);
EntityUtils.consume(entity1);
return null;
});
}
// There should be an auth strategy call for all successful message exchanges
Mockito.verify(authStrategy, Mockito.times(2)).select(Mockito.any(), Mockito.any(), Mockito.any());
assertThat(
responseQueue.stream().map(HttpResponse::getCode).collect(Collectors.toList()),
CoreMatchers.equalTo(Arrays.asList(200, 401, 200, 200, 401, 200)));
}
@Test
void testAuthenticationCredentialsCachingReAuthenticationOnDifferentRealm() throws Exception {
configureServerWithBasicAuth(new Authenticator() {
@Override
public boolean authenticate(final URIAuthority authority, final String requestUri, final String credentials) {
if (requestUri.equals("/this")) {
return "test:this".equals(credentials);
} else if (requestUri.equals("/that")) {
return "test:that".equals(credentials);
} else {
return "test:test".equals(credentials);
}
}
@Override
public String getRealm(final URIAuthority authority, final String requestUri) {
if (requestUri.equals("/this")) {
return "this realm";
} else if (requestUri.equals("/that")) {
return "that realm";
} else {
return "test realm";
}
}
}, bootstrap -> bootstrap.register("*", new EchoHandler()));
final HttpHost target = startServer();
final DefaultAuthenticationStrategy authStrategy = Mockito.spy(new DefaultAuthenticationStrategy());
configureClient(builder -> builder
.setTargetAuthenticationStrategy(authStrategy)
);
final TestClient client = client();
final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
.add(new AuthScope(target, "this realm", null), "test", "this".toCharArray())
.add(new AuthScope(target, "that realm", null), "test", "that".toCharArray())
.build();
final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credsProvider);
final HttpGet httpget1 = new HttpGet("/this");
client.execute(target, httpget1, context, response -> {
final HttpEntity entity1 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity1);
EntityUtils.consume(entity1);
return null;
});
final HttpGet httpget2 = new HttpGet("/this");
client.execute(target, httpget2, context, response -> {
final HttpEntity entity2 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity2);
EntityUtils.consume(entity2);
return null;
});
final HttpGet httpget3 = new HttpGet("/that");
client.execute(target, httpget3, context, response -> {
final HttpEntity entity3 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity3);
EntityUtils.consume(entity3);
return null;
});
Mockito.verify(authStrategy, Mockito.times(2)).select(Mockito.any(), Mockito.any(), Mockito.any());
}
@Test
void testAuthenticationUserinfoInRequest() throws Exception {
configureServer(bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpGet httpget = new HttpGet("http://test:test@" + target.toHostString() + "/");
final HttpClientContext context = HttpClientContext.create();
Assertions.assertThrows(ClientProtocolException.class, () -> client.execute(target, httpget, context, response -> null));
}
@Test
void testPreemptiveAuthentication() throws Exception {
final Authenticator authenticator = Mockito.spy(new BasicTestAuthenticator("test:test", "test realm"));
configureServerWithBasicAuth(authenticator,
bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final BasicScheme basicScheme = new BasicScheme();
basicScheme.initPreemptive(new UsernamePasswordCredentials("test", "test".toCharArray()));
final HttpClientContext context = HttpClientContext.create();
final AuthCache authCache = new BasicAuthCache();
authCache.put(target, basicScheme);
context.setAuthCache(authCache);
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
final HttpEntity entity1 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity1);
EntityUtils.consume(entity1);
return null;
});
Mockito.verify(authenticator).authenticate(Mockito.any(), Mockito.any(), Mockito.any());
}
@Test
void testPreemptiveAuthenticationFailure() throws Exception {
final Authenticator authenticator = Mockito.spy(new BasicTestAuthenticator("test:test", "test realm"));
configureServerWithBasicAuth(authenticator,
bootstrap -> bootstrap
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
final AuthCache authCache = new BasicAuthCache();
authCache.put(target, new BasicScheme());
context.setAuthCache(authCache);
context.setCredentialsProvider(CredentialsProviderBuilder.create()
.add(target, "test", "stuff".toCharArray())
.build());
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
final HttpEntity entity1 = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getCode());
Assertions.assertNotNull(entity1);
EntityUtils.consume(entity1);
return null;
});
Mockito.verify(authenticator).authenticate(Mockito.any(), Mockito.any(), Mockito.any());
}
static class ProxyAuthHandler implements HttpRequestHandler {
@Override
public void handle(
final ClassicHttpRequest request,
final ClassicHttpResponse response,
final HttpContext context) {
final String creds = (String) context.getAttribute("creds");
if (creds == null || !creds.equals("test:test")) {
response.setCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
} else {
response.setCode(HttpStatus.SC_OK);
final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
}
}
}
@Test
void testAuthenticationTargetAsProxy() throws Exception {
configureServer(bootstrap -> bootstrap
.register("*", new ProxyAuthHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
context.setCredentialsProvider(credsProvider);
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED, response.getCode());
EntityUtils.consume(entity);
return null;
});
}
@Test
void testConnectionCloseAfterAuthenticationSuccess() throws Exception {
configureServer(bootstrap -> bootstrap
.setExchangeHandlerDecorator(requestHandler ->
new AuthenticatingDecorator(requestHandler, new BasicTestAuthenticator("test:test", "test realm")) {
@Override
protected void customizeUnauthorizedResponse(final ClassicHttpResponse unauthorized) {
unauthorized.addHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
}
}
)
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
.add(target, "test", "test".toCharArray())
.build();
context.setCredentialsProvider(credsProvider);
for (int i = 0; i < 2; i++) {
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
EntityUtils.consume(response.getEntity());
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
return null;
});
}
}
@Test
void testReauthentication() throws Exception {
final BasicSchemeFactory myBasicAuthSchemeFactory = new BasicSchemeFactory() {
@Override
public AuthScheme create(final HttpContext context) {
return new BasicScheme() {
private static final long serialVersionUID = 1L;
@Override
public String getName() {
return "MyBasic";
}
};
}
};
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "test".toCharArray()));
final RequestConfig config = RequestConfig.custom()
.setTargetPreferredAuthSchemes(Collections.singletonList("MyBasic"))
.build();
final Registry<AuthSchemeFactory> authSchemeRegistry = RegistryBuilder.<AuthSchemeFactory>create()
.register("MyBasic", myBasicAuthSchemeFactory)
.build();
final Authenticator authenticator = new BasicTestAuthenticator("test:test", "test realm") {
private final AtomicLong count = new AtomicLong(0);
@Override
public boolean authenticate(final URIAuthority authority, final String requestUri, final String credentials) {
final boolean authenticated = super.authenticate(authority, requestUri, credentials);
if (authenticated) {
return this.count.incrementAndGet() % 4 != 0;
}
return false;
}
};
configureServer(bootstrap -> bootstrap
.setExchangeHandlerDecorator(requestHandler ->
new AuthenticatingDecorator(requestHandler, authenticator) {
@Override
protected void customizeUnauthorizedResponse(final ClassicHttpResponse unauthorized) {
unauthorized.removeHeaders(HttpHeaders.WWW_AUTHENTICATE);
unauthorized.addHeader(HttpHeaders.WWW_AUTHENTICATE, "MyBasic realm=\"test realm\"");
}
}
)
.register("*", new EchoHandler()));
final HttpHost target = startServer();
configureClient(builder -> builder
.setDefaultAuthSchemeRegistry(authSchemeRegistry)
);
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credsProvider);
for (int i = 0; i < 10; i++) {
final HttpGet httpget = new HttpGet("/");
httpget.setConfig(config);
client.execute(target, httpget, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
}
}
@Test
void testAuthenticationFallback() throws Exception {
configureServer(bootstrap -> bootstrap
.setExchangeHandlerDecorator(requestHandler ->
new AuthenticatingDecorator(requestHandler, new BasicTestAuthenticator("test:test", "test realm")) {
@Override
protected void customizeUnauthorizedResponse(final ClassicHttpResponse unauthorized) {
unauthorized.addHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.DIGEST + " realm=\"test realm\" invalid");
}
}
)
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final HttpClientContext context = HttpClientContext.create();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new UsernamePasswordCredentials("test", "test".toCharArray()));
context.setCredentialsProvider(credsProvider);
final HttpGet httpget = new HttpGet("/");
client.execute(target, httpget, context, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
Mockito.verify(credsProvider).getCredentials(
Mockito.eq(new AuthScope(target, "test realm", "basic")), Mockito.any());
}
private final static String CHARS = "0123456789abcdef";
@Test
void testBearerTokenAuthentication() throws Exception {
final SecureRandom secureRandom = SecureRandom.getInstanceStrong();
secureRandom.setSeed(System.currentTimeMillis());
final StringBuilder buf = new StringBuilder();
for (int i = 0; i < 16; i++) {
buf.append(CHARS.charAt(secureRandom.nextInt(CHARS.length() - 1)));
}
final String token = buf.toString();
configureServer(bootstrap -> bootstrap
.setExchangeHandlerDecorator(requestHandler ->
new AuthenticatingDecorator(
requestHandler,
new BearerAuthenticationHandler(),
new BasicTestAuthenticator(token, "test realm"))
)
.register("*", new EchoHandler()));
final HttpHost target = startServer();
final TestClient client = client();
final CredentialsProvider credsProvider = Mockito.mock(CredentialsProvider.class);
final HttpClientContext context1 = HttpClientContext.create();
context1.setCredentialsProvider(credsProvider);
final HttpGet httpget1 = new HttpGet("/");
client.execute(target, httpget1, context1, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
Mockito.verify(credsProvider).getCredentials(
Mockito.eq(new AuthScope(target, "test realm", "bearer")), Mockito.any());
final HttpClientContext context2 = HttpClientContext.create();
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new BearerToken(token));
context2.setCredentialsProvider(credsProvider);
final HttpGet httpget2 = new HttpGet("/");
client.execute(target, httpget2, context2, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
final HttpClientContext context3 = HttpClientContext.create();
Mockito.when(credsProvider.getCredentials(Mockito.any(), Mockito.any()))
.thenReturn(new BearerToken(token + "-expired"));
context3.setCredentialsProvider(credsProvider);
final HttpGet httpget3 = new HttpGet("/");
client.execute(target, httpget3, context3, response -> {
final HttpEntity entity = response.getEntity();
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getCode());
Assertions.assertNotNull(entity);
EntityUtils.consume(entity);
return null;
});
}
}
|
apache/helix | 36,380 | helix-core/src/test/java/org/apache/helix/controller/stages/TestIntermediateStateCalcStage.java | package org.apache.helix.controller.stages;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.ImmutableList;
import org.apache.helix.api.config.StateTransitionThrottleConfig;
import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
import org.apache.helix.model.ClusterConfig;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.Message;
import org.apache.helix.model.Partition;
import org.apache.helix.monitoring.mbeans.ClusterStatusMonitor;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TestIntermediateStateCalcStage extends BaseStageTest {
private ClusterConfig _clusterConfig;
@Test
public void testNoStateMissing() {
String resourcePrefix = "resource";
int nResource = 4;
int nPartition = 2;
int nReplica = 3;
String[] resources = new String[nResource];
for (int i = 0; i < nResource; i++) {
resources[i] = resourcePrefix + "_" + i;
}
preSetup(resources, nReplica, nReplica);
event.addAttribute(AttributeName.RESOURCES.name(), getResourceMap(resources, nPartition, "OnlineOffline"));
event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(),
getResourceMap(resources, nPartition, "OnlineOffline"));
// Initialize bestpossible state and current state
BestPossibleStateOutput bestPossibleStateOutput = new BestPossibleStateOutput();
CurrentStateOutput currentStateOutput = new CurrentStateOutput();
MessageOutput messageSelectOutput = new MessageOutput();
IntermediateStateOutput expectedResult = new IntermediateStateOutput();
_clusterConfig.setErrorOrRecoveryPartitionThresholdForLoadBalance(1);
setClusterConfig(_clusterConfig);
for (String resource : resources) {
IdealState is = accessor.getProperty(accessor.keyBuilder().idealStates(resource));
setSingleIdealState(is);
Map<String, List<String>> partitionMap = new HashMap<>();
for (int p = 0; p < nPartition; p++) {
Partition partition = new Partition(resource + "_" + p);
for (int r = 0; r < nReplica; r++) {
String instanceName = HOSTNAME_PREFIX + r;
partitionMap.put(partition.getPartitionName(), Collections.singletonList(instanceName));
if (resource.endsWith("0")) {
// Regular recovery balance
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
// add blocked state transition messages
Message pendingMessage = generateMessage("OFFLINE", "ONLINE", instanceName);
currentStateOutput.setPendingMessage(resource, partition, instanceName, pendingMessage);
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
// should be recovered:
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else if (resource.endsWith("1")) {
// Regular load balance
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
currentStateOutput.setCurrentState(resource, partition, instanceName + "-1", "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "DROPPED", instanceName + "-1"));
// should be recovered:
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else if (resource.endsWith("2")) {
// Recovery balance with transient states, should keep the current states in the output.
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "OFFLINE");
// should be kept unchanged:
expectedResult.setState(resource, partition, instanceName, "OFFLINE");
} else if (resource.endsWith("3")) {
// One unresolved error should not prevent recovery balance
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
if (p == 0) {
if (r == 0) {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ERROR");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ERROR");
// This partition is still ERROR
expectedResult.setState(resource, partition, instanceName, "ERROR");
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
messageSelectOutput.addMessage(resource, partition, generateMessage("OFFLINE", "ONLINE", instanceName));
// Recovery balance
expectedResult.setState(resource, partition, instanceName, "ONLINE");
}
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
currentStateOutput.setCurrentState(resource, partition, instanceName + "-1", "OFFLINE");
// load balance is throttled, so keep all current states
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "DROPPED", instanceName + "-1"));
expectedResult.setState(resource, partition, instanceName, "ONLINE");
// The following must be removed because now downward state transitions are allowed
// expectedResult.setState(resource, partition, instanceName + "-1", "OFFLINE");
}
} else if (resource.endsWith("4")) {
// Test that partitions with replicas to drop are dropping them when recovery is
// happening for other partitions
if (p == 0) {
// This partition requires recovery
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition, generateMessage("OFFLINE", "ONLINE", instanceName));
// After recovery, it should be back ONLINE
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else {
// Other partitions require dropping of replicas
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
currentStateOutput.setCurrentState(resource, partition, instanceName + "-1", "OFFLINE");
// BestPossibleState dictates that we only need one ONLINE replica
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName + "-1", "DROPPED");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "DROPPED", instanceName + "-1"));
// So instanceName-1 will NOT be expected to show up in expectedResult
expectedResult.setState(resource, partition, instanceName, "ONLINE");
expectedResult.setState(resource, partition, instanceName + "-1", "DROPPED");
}
} else if (resource.endsWith("5")) {
// Test that load balance bringing up a new replica does NOT happen with a recovery
// partition
if (p == 0) {
// Set up a partition requiring recovery
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition, generateMessage("OFFLINE", "ONLINE", instanceName));
// After recovery, it should be back ONLINE
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
// Check that load balance (bringing up a new node) did not take place
bestPossibleStateOutput.setState(resource, partition, instanceName + "-1", "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "ONLINE", instanceName + "-1"));
expectedResult.setState(resource, partition, instanceName, "ONLINE");
}
}
}
}
bestPossibleStateOutput.setPreferenceLists(resource, partitionMap);
}
event.addAttribute(AttributeName.BEST_POSSIBLE_STATE.name(), bestPossibleStateOutput);
event.addAttribute(AttributeName.MESSAGES_SELECTED.name(), messageSelectOutput);
event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
event.addAttribute(AttributeName.CURRENT_STATE_EXCLUDING_UNKNOWN.name(), currentStateOutput);
event.addAttribute(AttributeName.ControllerDataProvider.name(), new ResourceControllerDataProvider());
runStage(event, new ReadClusterDataStage());
runStage(event, new IntermediateStateCalcStage());
IntermediateStateOutput output = event.getAttribute(AttributeName.INTERMEDIATE_STATE.name());
for (String resource : resources) {
// Note Assert.assertEquals won't work. If "actual" is an empty map, it won't compare
// anything.
Assert.assertTrue(output.getPartitionStateMap(resource)
.getStateMap()
.equals(expectedResult.getPartitionStateMap(resource).getStateMap()));
}
}
@Test
public void testWithClusterConfigChange() {
String resourcePrefix = "resource";
int nResource = 1;
int nPartition = 2;
int nReplica = 3;
String[] resources = new String[nResource];
for (int i = 0; i < nResource; i++) {
resources[i] = resourcePrefix + "_" + i;
}
preSetup(resources, nReplica, nReplica);
event.addAttribute(AttributeName.RESOURCES.name(), getResourceMap(resources, nPartition, "OnlineOffline"));
event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(),
getResourceMap(resources, nPartition, "OnlineOffline"));
ClusterStatusMonitor monitor = new ClusterStatusMonitor(_clusterName);
monitor.active();
event.addAttribute(AttributeName.clusterStatusMonitor.name(), monitor);
// Initialize best possible state and current state
BestPossibleStateOutput bestPossibleStateOutput = new BestPossibleStateOutput();
MessageOutput messageSelectOutput = new MessageOutput();
CurrentStateOutput currentStateOutput = new CurrentStateOutput();
IntermediateStateOutput expectedResult = new IntermediateStateOutput();
for (String resource : resources) {
IdealState is = accessor.getProperty(accessor.keyBuilder().idealStates(resource));
setSingleIdealState(is);
Map<String, List<String>> partitionMap = new HashMap<>();
for (int p = 0; p < nPartition; p++) {
Partition partition = new Partition(resource + "_" + p);
for (int r = 0; r < nReplica; r++) {
String instanceName = HOSTNAME_PREFIX + r;
partitionMap.put(partition.getPartitionName(), Collections.singletonList(instanceName));
if (resource.endsWith("0")) {
// Test that when the threshold is set at a number greater than the number of error and
// recovery partitions, load balance DOES take place
_clusterConfig.setErrorOrRecoveryPartitionThresholdForLoadBalance(Integer.MAX_VALUE);
setClusterConfig(_clusterConfig);
if (p == 0) {
// Set up a partition requiring recovery
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition, generateMessage("OFFLINE", "ONLINE", instanceName));
// After recovery, it should be back ONLINE
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else {
// Ensure we have at least one ONLINE replica so that this partition does not need
// recovery
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
expectedResult.setState(resource, partition, instanceName, "ONLINE");
// This partition to bring up a replica (load balance will happen)
bestPossibleStateOutput.setState(resource, partition, instanceName + "-1", "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "ONLINE", instanceName + "-1"));
expectedResult.setState(resource, partition, instanceName + "-1", "ONLINE");
}
}
}
}
bestPossibleStateOutput.setPreferenceLists(resource, partitionMap);
}
event.addAttribute(AttributeName.BEST_POSSIBLE_STATE.name(), bestPossibleStateOutput);
event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
event.addAttribute(AttributeName.CURRENT_STATE_EXCLUDING_UNKNOWN.name(), currentStateOutput);
event.addAttribute(AttributeName.MESSAGES_SELECTED.name(), messageSelectOutput);
event.addAttribute(AttributeName.ControllerDataProvider.name(), new ResourceControllerDataProvider());
runStage(event, new ReadClusterDataStage());
runStage(event, new IntermediateStateCalcStage());
IntermediateStateOutput output = event.getAttribute(AttributeName.INTERMEDIATE_STATE.name());
// Validate that there are 0 resourced load balance been throttled
ClusterStatusMonitor clusterStatusMonitor =
event.getAttribute(AttributeName.clusterStatusMonitor.name());
Assert.assertEquals(clusterStatusMonitor.getNumOfResourcesRebalanceThrottledGauge(), 0);
Assert.assertEquals(clusterStatusMonitor.getResourceMonitor("resource_0")
.getRebalanceThrottledByErrorPartitionGauge(), 0);
for (String resource : resources) {
// Note Assert.assertEquals won't work. If "actual" is an empty map, it won't compare
// anything.
Assert.assertEquals(output.getPartitionStateMap(resource).getStateMap(),
expectedResult.getPartitionStateMap(resource).getStateMap());
}
}
@Test
public void testThrottleByErrorPartition() {
String resourcePrefix = "resource";
int nResource = 3;
int nPartition = 3;
int nReplica = 3;
String[] resources = new String[nResource];
for (int i = 0; i < nResource; i++) {
resources[i] = resourcePrefix + "_" + i;
}
preSetup(resources, nReplica, nReplica);
event.addAttribute(AttributeName.RESOURCES.name(),
getResourceMap(resources, nPartition, "OnlineOffline"));
event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(),
getResourceMap(resources, nPartition, "OnlineOffline"));
ClusterStatusMonitor monitor = new ClusterStatusMonitor(_clusterName);
monitor.active();
event.addAttribute(AttributeName.clusterStatusMonitor.name(), monitor);
// Initialize best possible state and current state
BestPossibleStateOutput bestPossibleStateOutput = new BestPossibleStateOutput();
MessageOutput messageSelectOutput = new MessageOutput();
CurrentStateOutput currentStateOutput = new CurrentStateOutput();
IntermediateStateOutput expectedResult = new IntermediateStateOutput();
_clusterConfig.setErrorOrRecoveryPartitionThresholdForLoadBalance(0);
setClusterConfig(_clusterConfig);
for (String resource : resources) {
IdealState is = accessor.getProperty(accessor.keyBuilder().idealStates(resource));
setSingleIdealState(is);
Map<String, List<String>> partitionMap = new HashMap<>();
for (int p = 0; p < nPartition; p++) {
Partition partition = new Partition(resource + "_" + p);
for (int r = 0; r < nReplica; r++) {
String instanceName = HOSTNAME_PREFIX + r;
partitionMap.put(partition.getPartitionName(), Collections.singletonList(instanceName));
// A resource with 2 replicas in error state and one need recovery in offline->online. error state
// throttle won't block recovery rebalance
if (resource.endsWith("0")) {
if (p <= 1) {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ERROR");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ERROR");
expectedResult.setState(resource, partition, instanceName, "ERROR");
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
expectedResult.setState(resource, partition, instanceName, "OFFLINE");
if (r == 0) {
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "ONLINE", instanceName));
expectedResult.setState(resource, partition, instanceName, "ONLINE");
}
}
} else if (resource.endsWith("1")) {
// A resource with 1 replicas in error state and one need load balance in offline->online. error state
// throttle will block load rebalance
if (p <= 0) {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ERROR");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ERROR");
expectedResult.setState(resource, partition, instanceName, "ERROR");
} else {
if (r == 0) {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else {
// even though there is ST msg, it should be throttled
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "ONLINE", instanceName));
expectedResult.setState(resource, partition, instanceName, "OFFLINE");
}
}
} else {
// A resource need regular load balance
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
currentStateOutput.setCurrentState(resource, partition, instanceName + "-1", "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "DROPPED", instanceName + "-1"));
// should be recovered:
expectedResult.setState(resource, partition, instanceName, "ONLINE");
}
}
}
bestPossibleStateOutput.setPreferenceLists(resource, partitionMap);
}
event.addAttribute(AttributeName.BEST_POSSIBLE_STATE.name(), bestPossibleStateOutput);
event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
event.addAttribute(AttributeName.CURRENT_STATE_EXCLUDING_UNKNOWN.name(), currentStateOutput);
event.addAttribute(AttributeName.MESSAGES_SELECTED.name(), messageSelectOutput);
event.addAttribute(AttributeName.ControllerDataProvider.name(),
new ResourceControllerDataProvider());
runStage(event, new ReadClusterDataStage());
runStage(event, new IntermediateStateCalcStage());
IntermediateStateOutput output = event.getAttribute(AttributeName.INTERMEDIATE_STATE.name());
// Validate that there are 2 resourced load balance been throttled
ClusterStatusMonitor clusterStatusMonitor =
event.getAttribute(AttributeName.clusterStatusMonitor.name());
Assert.assertEquals(clusterStatusMonitor.getNumOfResourcesRebalanceThrottledGauge(), 2);
Assert.assertEquals(clusterStatusMonitor.getResourceMonitor("resource_0")
.getRebalanceThrottledByErrorPartitionGauge(), 1);
Assert.assertEquals(clusterStatusMonitor.getResourceMonitor("resource_1")
.getRebalanceThrottledByErrorPartitionGauge(), 1);
Assert.assertEquals(clusterStatusMonitor.getResourceMonitor("resource_2")
.getRebalanceThrottledByErrorPartitionGauge(), 0);
for (String resource : resources) {
// Note Assert.assertEquals won't work. If "actual" is an empty map, it won't compare
// anything.
Assert.assertEquals(output.getPartitionStateMap(resource).getStateMap(),
expectedResult.getPartitionStateMap(resource).getStateMap());
}
}
@Test
public void testPartitionMissing() {
String resourcePrefix = "resource";
int nResource = 4;
int nPartition = 2;
int nReplica = 3;
String[] resources = new String[nResource];
for (int i = 0; i < nResource; i++) {
resources[i] = resourcePrefix + "_" + i;
}
preSetup(resources, nReplica, nReplica);
event.addAttribute(AttributeName.RESOURCES.name(), getResourceMap(resources, nPartition, "OnlineOffline"));
event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(),
getResourceMap(resources, nPartition, "OnlineOffline"));
// Initialize bestpossible state and current state
BestPossibleStateOutput bestPossibleStateOutput = new BestPossibleStateOutput();
CurrentStateOutput currentStateOutput = new CurrentStateOutput();
MessageOutput messageSelectOutput = new MessageOutput();
IntermediateStateOutput expectedResult = new IntermediateStateOutput();
_clusterConfig.setErrorOrRecoveryPartitionThresholdForLoadBalance(1);
setClusterConfig(_clusterConfig);
for (String resource : resources) {
IdealState is = accessor.getProperty(accessor.keyBuilder().idealStates(resource));
setSingleIdealState(is);
Map<String, List<String>> partitionMap = new HashMap<>();
for (int p = 0; p < nPartition; p++) {
Partition partition = new Partition(resource + "_" + p);
for (int r = 0; r < nReplica; r++) {
String instanceName = HOSTNAME_PREFIX + r;
// PartitionMap is used as a preferenceList.
// For the last partition, let us add null as preferenceList.
if (p != nPartition - 1) {
partitionMap.put(partition.getPartitionName(), Collections.singletonList(instanceName));
} else {
partitionMap.put(partition.getPartitionName(), null);
}
// TODO: The following code is same for testNoStateMissing
if (resource.endsWith("0")) {
// Regular recovery balance
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
// add blocked state transition messages
Message pendingMessage = generateMessage("OFFLINE", "ONLINE", instanceName);
currentStateOutput.setPendingMessage(resource, partition, instanceName, pendingMessage);
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
// should be recovered:
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else if (resource.endsWith("1")) {
// Regular load balance
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
currentStateOutput.setCurrentState(resource, partition, instanceName + "-1", "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "DROPPED", instanceName + "-1"));
// should be recovered:
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else if (resource.endsWith("2")) {
// Recovery balance with transient states, should keep the current states in the output.
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "OFFLINE");
// should be kept unchanged:
expectedResult.setState(resource, partition, instanceName, "OFFLINE");
} else if (resource.endsWith("3")) {
// One unresolved error should not prevent recovery balance
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
if (p == 0) {
if (r == 0) {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ERROR");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ERROR");
// This partition is still ERROR
expectedResult.setState(resource, partition, instanceName, "ERROR");
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
messageSelectOutput.addMessage(resource, partition, generateMessage("OFFLINE", "ONLINE", instanceName));
// Recovery balance
expectedResult.setState(resource, partition, instanceName, "ONLINE");
}
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
currentStateOutput.setCurrentState(resource, partition, instanceName + "-1", "OFFLINE");
// load balance is throttled, so keep all current states
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "DROPPED", instanceName + "-1"));
expectedResult.setState(resource, partition, instanceName, "ONLINE");
// The following must be removed because now downward state transitions are allowed
// expectedResult.setState(resource, partition, instanceName + "-1", "OFFLINE");
}
} else if (resource.endsWith("4")) {
// Test that partitions with replicas to drop are dropping them when recovery is
// happening for other partitions
if (p == 0) {
// This partition requires recovery
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition, generateMessage("OFFLINE", "ONLINE", instanceName));
// After recovery, it should be back ONLINE
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else {
// Other partitions require dropping of replicas
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
currentStateOutput.setCurrentState(resource, partition, instanceName + "-1", "OFFLINE");
// BestPossibleState dictates that we only need one ONLINE replica
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName + "-1", "DROPPED");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "DROPPED", instanceName + "-1"));
// So instanceName-1 will NOT be expected to show up in expectedResult
expectedResult.setState(resource, partition, instanceName, "ONLINE");
expectedResult.setState(resource, partition, instanceName + "-1", "DROPPED");
}
} else if (resource.endsWith("5")) {
// Test that load balance bringing up a new replica does NOT happen with a recovery
// partition
if (p == 0) {
// Set up a partition requiring recovery
currentStateOutput.setCurrentState(resource, partition, instanceName, "OFFLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
messageSelectOutput.addMessage(resource, partition, generateMessage("OFFLINE", "ONLINE", instanceName));
// After recovery, it should be back ONLINE
expectedResult.setState(resource, partition, instanceName, "ONLINE");
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
// Check that load balance (bringing up a new node) did not take place
bestPossibleStateOutput.setState(resource, partition, instanceName + "-1", "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "ONLINE", instanceName + "-1"));
expectedResult.setState(resource, partition, instanceName, "ONLINE");
}
}
}
}
bestPossibleStateOutput.setPreferenceLists(resource, partitionMap);
}
event.addAttribute(AttributeName.BEST_POSSIBLE_STATE.name(), bestPossibleStateOutput);
event.addAttribute(AttributeName.MESSAGES_SELECTED.name(), messageSelectOutput);
event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
event.addAttribute(AttributeName.CURRENT_STATE_EXCLUDING_UNKNOWN.name(), currentStateOutput);
event.addAttribute(AttributeName.ControllerDataProvider.name(), new ResourceControllerDataProvider());
runStage(event, new ReadClusterDataStage());
runStage(event, new IntermediateStateCalcStage());
IntermediateStateOutput output = event.getAttribute(AttributeName.INTERMEDIATE_STATE.name());
for (String resource : resources) {
// Note Assert.assertEquals won't work. If "actual" is an empty map, it won't compare
// anything.
Assert.assertTrue(output.getPartitionStateMap(resource)
.getStateMap()
.equals(expectedResult.getPartitionStateMap(resource).getStateMap()));
}
}
@Test
public void testMessageAlreadyApplied() {
String resourcePrefix = "resource";
int nResource = 1;
int nPartition = 5;
int nReplica = 1;
String[] resources = new String[nResource];
for (int i = 0; i < nResource; i++) {
resources[i] = resourcePrefix + "_" + i;
}
preSetup(resources, nReplica, nReplica);
event.addAttribute(AttributeName.RESOURCES.name(), getResourceMap(resources, nPartition, "OnlineOffline"));
event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(),
getResourceMap(resources, nPartition, "OnlineOffline"));
// Initialize bestpossible state and current state
BestPossibleStateOutput bestPossibleStateOutput = new BestPossibleStateOutput();
CurrentStateOutput currentStateOutput = new CurrentStateOutput();
MessageOutput messageSelectOutput = new MessageOutput();
IntermediateStateOutput expectedResult = new IntermediateStateOutput();
_clusterConfig.setErrorOrRecoveryPartitionThresholdForLoadBalance(1);
setClusterConfig(_clusterConfig);
for (String resource : resources) {
IdealState is = accessor.getProperty(accessor.keyBuilder().idealStates(resource));
setSingleIdealState(is);
Map<String, List<String>> partitionMap = new HashMap<>();
for (int p = 0; p < nPartition; p++) {
Partition partition = new Partition(resource + "_" + p);
for (int r = 0; r < nReplica; r++) {
String instanceName = HOSTNAME_PREFIX + r;
// PartitionMap is used as a preferenceList.
partitionMap.put(partition.getPartitionName(), Collections.singletonList(instanceName));
if (p == 0) {
// Dont set current state. set best possible on another node
// Set a pending message to drop a replica that doesn't exist in currentState
currentStateOutput.setPendingMessage(resource, partition, instanceName,
generateMessage("OFFLINE", "DROPPED", instanceName));
// Set pending message to bootstrap elsewhere
String dummyInstance = "dummy_instance";
bestPossibleStateOutput.setState(resource, partition, dummyInstance, "ONLINE");
messageSelectOutput.addMessage(resource, partition,
generateMessage("OFFLINE", "ONLINE", dummyInstance));
expectedResult.setState(resource, partition, dummyInstance, "ONLINE");
} else {
currentStateOutput.setCurrentState(resource, partition, instanceName, "ONLINE");
bestPossibleStateOutput.setState(resource, partition, instanceName, "ONLINE");
expectedResult.setState(resource, partition, instanceName, "ONLINE");
}
}
}
bestPossibleStateOutput.setPreferenceLists(resource, partitionMap);
}
event.addAttribute(AttributeName.BEST_POSSIBLE_STATE.name(), bestPossibleStateOutput);
event.addAttribute(AttributeName.MESSAGES_SELECTED.name(), messageSelectOutput);
event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
event.addAttribute(AttributeName.CURRENT_STATE_EXCLUDING_UNKNOWN.name(), currentStateOutput);
event.addAttribute(AttributeName.ControllerDataProvider.name(), new ResourceControllerDataProvider());
runStage(event, new ReadClusterDataStage());
runStage(event, new IntermediateStateCalcStage());
IntermediateStateOutput output = event.getAttribute(AttributeName.INTERMEDIATE_STATE.name());
for (String resource : resources) {
// Note Assert.assertEquals won't work. If "actual" is an empty map, it won't compare
// anything.
Assert.assertTrue(output.getPartitionStateMap(resource)
.getStateMap()
.equals(expectedResult.getPartitionStateMap(resource).getStateMap()));
}
}
private void preSetup(String[] resources, int numOfLiveInstances, int numOfReplicas) {
setupIdealState(numOfLiveInstances, resources, numOfLiveInstances, numOfReplicas,
IdealState.RebalanceMode.FULL_AUTO, "OnlineOffline");
setupStateModel();
setupInstances(numOfLiveInstances);
setupLiveInstances(numOfLiveInstances);
// Set up cluster configs
_clusterConfig = accessor.getProperty(accessor.keyBuilder().clusterConfig());
_clusterConfig.setStateTransitionThrottleConfigs(ImmutableList.of(
new StateTransitionThrottleConfig(StateTransitionThrottleConfig.RebalanceType.RECOVERY_BALANCE,
StateTransitionThrottleConfig.ThrottleScope.INSTANCE, 3),
new StateTransitionThrottleConfig(StateTransitionThrottleConfig.RebalanceType.LOAD_BALANCE,
StateTransitionThrottleConfig.ThrottleScope.INSTANCE, 3)));
setClusterConfig(_clusterConfig);
}
}
|
apache/tomee | 36,605 | container/openejb-core/src/test/java/org/apache/openejb/config/InheritenceTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.openejb.config;
import junit.framework.TestCase;
import org.apache.openejb.assembler.classic.Assembler;
import org.apache.openejb.assembler.classic.CallbackInfo;
import org.apache.openejb.assembler.classic.EjbJarInfo;
import org.apache.openejb.assembler.classic.EjbLocalReferenceInfo;
import org.apache.openejb.assembler.classic.EjbReferenceInfo;
import org.apache.openejb.assembler.classic.EnvEntryInfo;
import org.apache.openejb.assembler.classic.HandlerChainInfo;
import org.apache.openejb.assembler.classic.HandlerInfo;
import org.apache.openejb.assembler.classic.InitMethodInfo;
import org.apache.openejb.assembler.classic.InjectionInfo;
import org.apache.openejb.assembler.classic.JndiEncInfo;
import org.apache.openejb.assembler.classic.NamedMethodInfo;
import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
import org.apache.openejb.assembler.classic.PortRefInfo;
import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
import org.apache.openejb.assembler.classic.RemoveMethodInfo;
import org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo;
import org.apache.openejb.assembler.classic.ResourceReferenceInfo;
import org.apache.openejb.assembler.classic.SecurityRoleReferenceInfo;
import org.apache.openejb.assembler.classic.SecurityServiceInfo;
import org.apache.openejb.assembler.classic.ServiceReferenceInfo;
import org.apache.openejb.assembler.classic.StatefulBeanInfo;
import org.apache.openejb.assembler.classic.StatefulSessionContainerInfo;
import org.apache.openejb.assembler.classic.TransactionServiceInfo;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.StatefulBean;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.RolesAllowed;
import jakarta.annotation.security.RunAs;
import jakarta.ejb.CreateException;
import jakarta.ejb.EJB;
import jakarta.ejb.EJBHome;
import jakarta.ejb.EJBLocalHome;
import jakarta.ejb.EJBLocalObject;
import jakarta.ejb.EJBObject;
import jakarta.ejb.Init;
import jakarta.ejb.Local;
import jakarta.ejb.LocalHome;
import jakarta.ejb.PostActivate;
import jakarta.ejb.PrePassivate;
import jakarta.ejb.Remote;
import jakarta.ejb.RemoteHome;
import jakarta.ejb.Remove;
import jakarta.ejb.Timeout;
import jakarta.ejb.Timer;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.ejb.TransactionManagement;
import jakarta.ejb.TransactionManagementType;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.InvocationContext;
import jakarta.jms.Topic;
import javax.sql.DataSource;
import java.rmi.RemoteException;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
/**
* @version $Rev$ $Date$
*/
public class InheritenceTest extends TestCase {
public void test() throws Exception {
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
assembler.createContainer(config.configureService(StatefulSessionContainerInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
ejbJar.addEnterpriseBean(new StatefulBean(Red.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
final StatefulBeanInfo expected = (StatefulBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
final StatefulBeanInfo actual = (StatefulBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
assertEquals("transactionType", expected.transactionType, actual.transactionType);
assertEquals("runAs", expected.runAs, actual.runAs);
assertEquals("businessLocal", expected.businessLocal, actual.businessLocal);
assertEquals("businessRemote", expected.businessRemote, actual.businessRemote);
assertEquals("local", expected.local, actual.local);
assertEquals("localHome", expected.localHome, actual.localHome);
assertEquals("remote", expected.remote, actual.remote);
assertEquals("home", expected.home, actual.home);
assertEquals("timeout", expected.timeoutMethod, actual.timeoutMethod);
assertCallbackInfos("postActivate", expected.postActivate, actual.postActivate);
assertCallbackInfos("prePassivate", expected.prePassivate, actual.prePassivate);
assertCallbackInfos("postConstruct", expected.postConstruct, actual.postConstruct);
assertCallbackInfos("preDestroy", expected.preDestroy, actual.preDestroy);
assertCallbackInfos("preDestroy", expected.aroundInvoke, actual.aroundInvoke);
assertRemoveMethodInfos("removeMethods", expected.removeMethods, actual.removeMethods);
assertInitMethodInfos("initMethods", expected.initMethods, actual.initMethods);
assertSecurityRoleReferenceInfos("securityRoleReferences", expected.securityRoleReferences, actual.securityRoleReferences);
// comp/ComponentName is different
assertEquals(1, expected.jndiEnc.envEntries.size());
assertEquals(1, actual.jndiEnc.envEntries.size());
assertEquals("comp/ComponentName", expected.jndiEnc.envEntries.get(0).referenceName);
assertEquals("Color", expected.jndiEnc.envEntries.get(0).value);
assertEquals("comp/ComponentName", actual.jndiEnc.envEntries.get(0).referenceName);
assertEquals("Red", actual.jndiEnc.envEntries.get(0).value);
expected.jndiEnc.envEntries.clear();
actual.jndiEnc.envEntries.clear();
assertEquals("jndiEnc", expected.jndiEnc, actual.jndiEnc);
}
@Local
public static interface ColorLocal {
}
@Remote
public static interface ColorRemote {
}
public static interface ColorLocal2 {
}
public static interface ColorRemote2 {
}
public static interface ColorEjbHome extends EJBHome {
ColorEjbObject create() throws CreateException, RemoteException;
}
public static interface ColorEjbObject extends EJBObject {
}
public static interface ColorEjbLocalHome extends EJBLocalHome {
ColorEjbLocalObject create() throws CreateException;
}
public static interface ColorEjbLocalObject extends EJBLocalObject {
}
@EJB(name = "colorClassEjb", beanInterface = ColorLocal.class)
@Resource(name = "colorClassResource", type = DataSource.class)
@RolesAllowed({"ColorManager"})
@DeclareRoles({"ColorGuy", "ColorGal"})
@RunAs("ColorManager")
@TransactionManagement(TransactionManagementType.BEAN)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
@Local({ColorLocal2.class})
@Remote({ColorRemote2.class})
@LocalHome(ColorEjbLocalHome.class)
@RemoteHome(ColorEjbHome.class)
public static class Color implements ColorLocal, ColorRemote {
@EJB
private ColorRemote colorFieldEjb;
@Resource
private DataSource colorFieldResource;
@Resource
private Topic colorFieldResourceEnv;
public void methodOne() {
}
public void methodTwo() {
}
public void methodThree() {
}
public void methodFour() {
}
@Timeout
public void colorTimeout(final Timer timer) {
}
@AroundInvoke
public Object invoke(final InvocationContext context) throws Exception {
return null;
}
@PostConstruct
private void colorPostConstruct() {
}
@PreDestroy
private void colorPreDestroy() {
}
@Init
public void colorInit() {
}
@Remove
public void colorRemove() {
}
@PrePassivate
public void colorPrePassivate() {
}
@PostActivate
public void colorPostActivate() {
}
}
public static class Red extends Color {
}
// ------------------------------------------------------------------------------------------------------
//
// Assert methods
//
// ------------------------------------------------------------------------------------------------------
public static void assertEquals(final String m, final JndiEncInfo a, final JndiEncInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final JndiEncInfo a, final JndiEncInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!equalsEnvEntryInfos(a.envEntries, b.envEntries)) return false;
if (!equalsEjbReferenceInfos(a.ejbReferences, b.ejbReferences)) return false;
if (!equalsEjbLocalReferenceInfos(a.ejbLocalReferences, b.ejbLocalReferences)) return false;
if (!equalsResourceReferenceInfos(a.resourceRefs, b.resourceRefs)) return false;
if (!equalsPersistenceUnitReferenceInfos(a.persistenceUnitRefs, b.persistenceUnitRefs)) return false;
if (!equalsPersistenceContextReferenceInfos(a.persistenceContextRefs, b.persistenceContextRefs)) return false;
if (!equalsResourceEnvReferenceInfos(a.resourceEnvRefs, b.resourceEnvRefs)) return false;
if (!equalsServiceReferenceInfos(a.serviceRefs, b.serviceRefs)) return false;
return true;
}
// -- ReferenceLocationInfo --------------------------------//
public static void assertReferenceLocationInfos(final String s, final List<ReferenceLocationInfo> expected, final List<ReferenceLocationInfo> actual) {
assertTrue(s, equalsReferenceLocationInfos(expected, actual));
}
public static boolean equalsReferenceLocationInfos(final List<ReferenceLocationInfo> expected, final List<ReferenceLocationInfo> actual) {
return new ReferenceLocationInfoComparator().compare(expected, actual);
}
public static class ReferenceLocationInfoComparator extends ListComparator<ReferenceLocationInfo> {
public boolean compare(final ReferenceLocationInfo a, final ReferenceLocationInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final ReferenceLocationInfo a, final ReferenceLocationInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final ReferenceLocationInfo a, final ReferenceLocationInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.jndiName, b.jndiName)) return false;
if (!Objects.equals(a.jndiProviderId, b.jndiProviderId))
return false;
return true;
}
// -- EnvEntryInfo --------------------------------//
public static void assertEnvEntryInfos(final String s, final List<EnvEntryInfo> expected, final List<EnvEntryInfo> actual) {
assertTrue(s, equalsEnvEntryInfos(expected, actual));
}
public static boolean equalsEnvEntryInfos(final List<EnvEntryInfo> expected, final List<EnvEntryInfo> actual) {
return new EnvEntryInfoComparator().compare(expected, actual);
}
public static class EnvEntryInfoComparator extends ListComparator<EnvEntryInfo> {
public boolean compare(final EnvEntryInfo a, final EnvEntryInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final EnvEntryInfo a, final EnvEntryInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final EnvEntryInfo a, final EnvEntryInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.referenceName, b.referenceName)) return false;
if (!Objects.equals(a.type, b.type)) return false;
if (!Objects.equals(a.value, b.value)) return false;
if (!equals(a.location, b.location)) return false;
if (!equalsInjectionInfos(a.targets, b.targets)) return false;
return true;
}
// -- InjectionInfo --------------------------------//
public static void assertInjectionInfos(final String s, final List<InjectionInfo> expected, final List<InjectionInfo> actual) {
assertTrue(s, equalsInjectionInfos(expected, actual));
}
public static boolean equalsInjectionInfos(final List<InjectionInfo> expected, final List<InjectionInfo> actual) {
return new InjectionInfoComparator().compare(expected, actual);
}
public static class InjectionInfoComparator extends ListComparator<InjectionInfo> {
public boolean compare(final InjectionInfo a, final InjectionInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String s, final InjectionInfo a, final InjectionInfo b) {
assertTrue(s, equals(a, b));
}
public static boolean equals(final InjectionInfo a, final InjectionInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.propertyName, b.propertyName)) return false;
if (!Objects.equals(a.className, b.className)) return false;
return true;
}
// -- EjbReferenceInfo --------------------------------//
public static void assertEjbReferenceInfos(final String s, final List<EjbReferenceInfo> expected, final List<EjbReferenceInfo> actual) {
assertTrue(s, equalsEjbReferenceInfos(expected, actual));
}
public static boolean equalsEjbReferenceInfos(final List<EjbReferenceInfo> expected, final List<EjbReferenceInfo> actual) {
return new EjbReferenceInfoComparator().compare(expected, actual);
}
public static class EjbReferenceInfoComparator extends ListComparator<EjbReferenceInfo> {
public boolean compare(final EjbReferenceInfo a, final EjbReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final EjbReferenceInfo a, final EjbReferenceInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final EjbReferenceInfo a, final EjbReferenceInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.referenceName, b.referenceName)) return false;
if (!Objects.equals(a.homeClassName, b.homeClassName)) return false;
if (!Objects.equals(a.interfaceClassName, b.interfaceClassName))
return false;
if (!Objects.equals(a.ejbDeploymentId, b.ejbDeploymentId))
return false;
if (!Objects.equals(a.link, b.link)) return false;
if (a.externalReference != b.externalReference) return false;
if (!equals(a.location, b.location)) return false;
if (!equalsInjectionInfos(a.targets, b.targets)) return false;
return true;
}
// -- EjbLocalReferenceInfo --------------------------------//
public static void assertEjbLocalReferenceInfos(final String s, final List<EjbLocalReferenceInfo> expected, final List<EjbLocalReferenceInfo> actual) {
assertTrue(s, equalsEjbLocalReferenceInfos(expected, actual));
}
public static boolean equalsEjbLocalReferenceInfos(final List<EjbLocalReferenceInfo> expected, final List<EjbLocalReferenceInfo> actual) {
return new EjbLocalReferenceInfoComparator().compare(expected, actual);
}
public static class EjbLocalReferenceInfoComparator extends ListComparator<EjbLocalReferenceInfo> {
public boolean compare(final EjbLocalReferenceInfo a, final EjbLocalReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
// -- ResourceReferenceInfo --------------------------------//
public static void assertResourceReferenceInfos(final String s, final List<ResourceReferenceInfo> expected, final List<ResourceReferenceInfo> actual) {
assertTrue(s, equalsResourceReferenceInfos(expected, actual));
}
public static boolean equalsResourceReferenceInfos(final List<ResourceReferenceInfo> expected, final List<ResourceReferenceInfo> actual) {
return new ResourceReferenceInfoComparator().compare(expected, actual);
}
public static class ResourceReferenceInfoComparator extends ListComparator<ResourceReferenceInfo> {
public boolean compare(final ResourceReferenceInfo a, final ResourceReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final ResourceReferenceInfo a, final ResourceReferenceInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final ResourceReferenceInfo a, final ResourceReferenceInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.referenceName, b.referenceName)) return false;
if (!Objects.equals(a.referenceType, b.referenceType)) return false;
if (!Objects.equals(a.referenceAuth, b.referenceAuth)) return false;
if (!Objects.equals(a.resourceID, b.resourceID)) return false;
if (!Objects.equals(a.properties, b.properties)) return false;
if (!equals(a.location, b.location)) return false;
if (!equalsInjectionInfos(a.targets, b.targets)) return false;
return true;
}
// -- PersistenceUnitReferenceInfo --------------------------------//
public static void assertPersistenceUnitReferenceInfos(final String s, final List<PersistenceUnitReferenceInfo> expected, final List<PersistenceUnitReferenceInfo> actual) {
assertTrue(s, equalsPersistenceUnitReferenceInfos(expected, actual));
}
public static boolean equalsPersistenceUnitReferenceInfos(final List<PersistenceUnitReferenceInfo> expected, final List<PersistenceUnitReferenceInfo> actual) {
return new PersistenceUnitReferenceInfoComparator().compare(expected, actual);
}
public static class PersistenceUnitReferenceInfoComparator extends ListComparator<PersistenceUnitReferenceInfo> {
public boolean compare(final PersistenceUnitReferenceInfo a, final PersistenceUnitReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final PersistenceUnitReferenceInfo a, final PersistenceUnitReferenceInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final PersistenceUnitReferenceInfo a, final PersistenceUnitReferenceInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.referenceName, b.referenceName)) return false;
if (!Objects.equals(a.persistenceUnitName, b.persistenceUnitName))
return false;
if (!Objects.equals(a.unitId, b.unitId)) return false;
if (!equals(a.location, b.location)) return false;
if (!equalsInjectionInfos(a.targets, b.targets)) return false;
return true;
}
// -- PersistenceContextReferenceInfo --------------------------------//
public static void assertPersistenceContextReferenceInfos(final String s, final List<PersistenceContextReferenceInfo> expected, final List<PersistenceContextReferenceInfo> actual) {
assertTrue(s, equalsPersistenceContextReferenceInfos(expected, actual));
}
public static boolean equalsPersistenceContextReferenceInfos(final List<PersistenceContextReferenceInfo> expected, final List<PersistenceContextReferenceInfo> actual) {
return new PersistenceContextReferenceInfoComparator().compare(expected, actual);
}
public static class PersistenceContextReferenceInfoComparator extends ListComparator<PersistenceContextReferenceInfo> {
public boolean compare(final PersistenceContextReferenceInfo a, final PersistenceContextReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final PersistenceContextReferenceInfo a, final PersistenceContextReferenceInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final PersistenceContextReferenceInfo a, final PersistenceContextReferenceInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.referenceName, b.referenceName)) return false;
if (!Objects.equals(a.persistenceUnitName, b.persistenceUnitName))
return false;
if (!Objects.equals(a.unitId, b.unitId)) return false;
if (a.extended != b.extended) return false;
if (a.properties != null ? !a.properties.equals(b.properties) : b.properties != null) return false;
if (!equals(a.location, b.location)) return false;
if (!equalsInjectionInfos(a.targets, b.targets)) return false;
return true;
}
// -- ResourceEnvReferenceInfo --------------------------------//
public static void assertResourceEnvReferenceInfos(final String s, final List<ResourceEnvReferenceInfo> expected, final List<ResourceEnvReferenceInfo> actual) {
assertTrue(s, equalsResourceEnvReferenceInfos(expected, actual));
}
public static boolean equalsResourceEnvReferenceInfos(final List<ResourceEnvReferenceInfo> expected, final List<ResourceEnvReferenceInfo> actual) {
return new ResourceEnvReferenceInfoComparator().compare(expected, actual);
}
public static class ResourceEnvReferenceInfoComparator extends ListComparator<ResourceEnvReferenceInfo> {
public boolean compare(final ResourceEnvReferenceInfo a, final ResourceEnvReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final ResourceEnvReferenceInfo a, final ResourceEnvReferenceInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final ResourceEnvReferenceInfo a, final ResourceEnvReferenceInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.referenceName, b.referenceName))
return false;
if (!Objects.equals(a.resourceEnvRefType, b.resourceEnvRefType))
return false;
if (!Objects.equals(a.mappedName, b.mappedName)) return false;
if (!Objects.equals(a.resourceID, b.resourceID)) return false;
if (!equals(a.location, b.location)) return false;
if (!equalsInjectionInfos(a.targets, b.targets)) return false;
return true;
}
// -- ServiceReferenceInfo --------------------------------//
public static void assertServiceReferenceInfos(final String s, final List<ServiceReferenceInfo> expected, final List<ServiceReferenceInfo> actual) {
assertTrue(s, equalsServiceReferenceInfos(expected, actual));
}
public static boolean equalsServiceReferenceInfos(final List<ServiceReferenceInfo> expected, final List<ServiceReferenceInfo> actual) {
return new ServiceReferenceInfoComparator().compare(expected, actual);
}
public static class ServiceReferenceInfoComparator extends ListComparator<ServiceReferenceInfo> {
public boolean compare(final ServiceReferenceInfo a, final ServiceReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final ServiceReferenceInfo a, final ServiceReferenceInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final ServiceReferenceInfo a, final ServiceReferenceInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.referenceName, b.referenceName)) return false;
if (!Objects.equals(a.serviceQName, b.serviceQName)) return false;
if (!Objects.equals(a.serviceType, b.serviceType)) return false;
if (!Objects.equals(a.portQName, b.portQName)) return false;
if (!Objects.equals(a.referenceType, b.referenceType)) return false;
if (!Objects.equals(a.wsdlFile, b.wsdlFile)) return false;
if (!Objects.equals(a.jaxrpcMappingFile, b.jaxrpcMappingFile))
return false;
if (!Objects.equals(a.id, b.id)) return false;
if (!equalsHandlerChainInfos(a.handlerChains, b.handlerChains)) return false;
if (!equalsPortRefInfos(a.portRefs, b.portRefs)) return false;
if (!equals(a.location, b.location)) return false;
if (!equalsInjectionInfos(a.targets, b.targets)) return false;
return true;
}
// -- HandlerChainInfo --------------------------------//
public static void assertHandlerChainInfos(final String s, final List<HandlerChainInfo> expected, final List<HandlerChainInfo> actual) {
assertTrue(s, equalsHandlerChainInfos(expected, actual));
}
public static boolean equalsHandlerChainInfos(final List<HandlerChainInfo> expected, final List<HandlerChainInfo> actual) {
return new HandlerChainInfoComparator().compare(expected, actual);
}
public static class HandlerChainInfoComparator extends ListComparator<HandlerChainInfo> {
public boolean compare(final HandlerChainInfo a, final HandlerChainInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String s, final HandlerChainInfo a, final HandlerChainInfo b) {
assertTrue(s, equals(a, b));
}
public static boolean equals(final HandlerChainInfo a, final HandlerChainInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.serviceNamePattern, b.serviceNamePattern))
return false;
if (!Objects.equals(a.portNamePattern, b.portNamePattern))
return false;
if (a.protocolBindings != null ? !a.protocolBindings.equals(b.protocolBindings) : b.protocolBindings != null)
return false;
if (!equalsHandlerInfos(a.handlers, b.handlers)) return false;
return true;
}
// -- HandlerInfo --------------------------------//
public static void assertHandlerInfos(final String s, final List<HandlerInfo> expected, final List<HandlerInfo> actual) {
assertTrue(s, equalsHandlerInfos(expected, actual));
}
public static boolean equalsHandlerInfos(final List<HandlerInfo> expected, final List<HandlerInfo> actual) {
return new HandlerInfoComparator().compare(expected, actual);
}
public static class HandlerInfoComparator extends ListComparator<HandlerInfo> {
public boolean compare(final HandlerInfo a, final HandlerInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String s, final HandlerInfo a, final HandlerInfo b) {
assertTrue(s, equals(a, b));
}
public static boolean equals(final HandlerInfo a, final HandlerInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.handlerClass, b.handlerClass)) return false;
if (!Objects.equals(a.handlerName, b.handlerName)) return false;
if (a.initParams != null ? !a.initParams.equals(b.initParams) : b.initParams != null) return false;
if (a.soapHeaders != null ? !a.soapHeaders.equals(b.soapHeaders) : b.soapHeaders != null) return false;
if (a.soapRoles != null ? !a.soapRoles.equals(b.soapRoles) : b.soapRoles != null) return false;
return true;
}
// -- PortRefInfo --------------------------------//
public static void assertPortRefInfos(final String s, final List<PortRefInfo> expected, final List<PortRefInfo> actual) {
assertTrue(s, equalsPortRefInfos(expected, actual));
}
public static boolean equalsPortRefInfos(final List<PortRefInfo> expected, final List<PortRefInfo> actual) {
return new PortRefInfoComparator().compare(expected, actual);
}
public static class PortRefInfoComparator extends ListComparator<PortRefInfo> {
public boolean compare(final PortRefInfo a, final PortRefInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String s, final PortRefInfo a, final PortRefInfo b) {
assertTrue(s, equals(a, b));
}
public static boolean equals(final PortRefInfo a, final PortRefInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.qname, b.qname)) return false;
if (!Objects.equals(a.serviceEndpointInterface, b.serviceEndpointInterface))
return false;
if (a.properties != null ? !a.properties.equals(b.properties) : b.properties != null) return false;
if (a.enableMtom != b.enableMtom) return false;
return true;
}
// -- CallbackInfo --------------------------------//
public static void assertCallbackInfos(final String s, final List<CallbackInfo> expected, final List<CallbackInfo> actual) {
assertTrue(s, equalsCallbackInfos(expected, actual));
}
public static boolean equalsCallbackInfos(final List<CallbackInfo> expected, final List<CallbackInfo> actual) {
return new CallbackInfoComparator().compare(expected, actual);
}
public static class CallbackInfoComparator extends ListComparator<CallbackInfo> {
public boolean compare(final CallbackInfo a, final CallbackInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final CallbackInfo a, final CallbackInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final CallbackInfo a, final CallbackInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.className, b.className)) return false;
if (!Objects.equals(a.method, b.method)) return false;
return true;
}
// -- SecurityRoleReferenceInfo --------------------------------//
public static void assertSecurityRoleReferenceInfos(final String s, final List<SecurityRoleReferenceInfo> expected, final List<SecurityRoleReferenceInfo> actual) {
assertTrue(s, equalsSecurityRoleReferenceInfos(expected, actual));
}
public static boolean equalsSecurityRoleReferenceInfos(final List<SecurityRoleReferenceInfo> expected, final List<SecurityRoleReferenceInfo> actual) {
return new SecurityRoleReferenceInfoComparator().compare(expected, actual);
}
public static class SecurityRoleReferenceInfoComparator extends ListComparator<SecurityRoleReferenceInfo> {
public boolean compare(final SecurityRoleReferenceInfo a, final SecurityRoleReferenceInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final SecurityRoleReferenceInfo a, final SecurityRoleReferenceInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final SecurityRoleReferenceInfo a, final SecurityRoleReferenceInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.roleName, b.roleName)) return false;
if (!Objects.equals(a.roleLink, b.roleLink)) return false;
return true;
}
// -- RemoveMethodInfo --------------------------------//
public static void assertRemoveMethodInfos(final String s, final List<RemoveMethodInfo> expected, final List<RemoveMethodInfo> actual) {
assertTrue(s, equalsRemoveMethodInfos(expected, actual));
}
public static boolean equalsRemoveMethodInfos(final List<RemoveMethodInfo> expected, final List<RemoveMethodInfo> actual) {
return new RemoveMethodInfoComparator().compare(expected, actual);
}
public static class RemoveMethodInfoComparator extends ListComparator<RemoveMethodInfo> {
public boolean compare(final RemoveMethodInfo a, final RemoveMethodInfo b) {
return InheritenceTest.equals(a, b);
}
}
public static void assertEquals(final String m, final RemoveMethodInfo a, final RemoveMethodInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final RemoveMethodInfo a, final RemoveMethodInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (a.retainIfException != b.retainIfException) return false;
return equals(a.beanMethod, b.beanMethod);
}
public static void assertInitMethodInfos(final String s, final List<InitMethodInfo> expected, final List<InitMethodInfo> actual) {
assertTrue(s, equalsInitMethodInfos(expected, actual));
}
public static boolean equalsInitMethodInfos(final List<InitMethodInfo> expected, final List<InitMethodInfo> actual) {
return new InitMethodInfoComparator().compare(expected, actual);
}
public static class InitMethodInfoComparator extends ListComparator<InitMethodInfo> {
public boolean compare(final InitMethodInfo o1, final InitMethodInfo o2) {
return InheritenceTest.equals(o1, o2);
}
}
public static void assertEquals(final String m, final InitMethodInfo a, final InitMethodInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final InitMethodInfo a, final InitMethodInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!equals(a.beanMethod, b.beanMethod)) return false;
if (!equals(a.createMethod, b.createMethod)) return false;
return true;
}
public static void assertEquals(final String m, final NamedMethodInfo a, final NamedMethodInfo b) {
assertTrue(m, equals(a, b));
}
public static boolean equals(final NamedMethodInfo a, final NamedMethodInfo b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Objects.equals(a.id, b.id)) return false;
if (!Objects.equals(a.methodName, b.methodName)) return false;
if (!Objects.equals(a.methodParams, b.methodParams)) return false;
return true;
}
public static void assertList(final String s, final List expected, final List actual, final ListComparator comparator) {
assertTrue(s, comparator.compare(expected, actual));
}
public static abstract class ListComparator<T> {
public boolean compare(final List<T> listA, final List<T> listB) {
if (listA == listB) return true;
final ListIterator iA = listA.listIterator();
final ListIterator iB = listB.listIterator();
while (iA.hasNext() && iB.hasNext()) {
final T a = (T) iA.next();
final T b = (T) iB.next();
if (!(a == null ? b == null : compare(a, b))) {
return false;
}
}
return !(iA.hasNext() || iB.hasNext());
}
public abstract boolean compare(T o1, T o2);
}
}
|
apache/maven-surefire | 36,294 | maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.plugin.failsafe;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
import org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.surefire.api.suite.RunResult;
import org.apache.maven.surefire.extensions.ForkNodeFactory;
import static org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils.writeSummary;
/**
* Run integration tests using Surefire.
*
* @author Jason van Zyl
* @author Stephen Connolly
*/
@Mojo(
name = "integration-test",
requiresProject = true,
requiresDependencyResolution = ResolutionScope.TEST,
defaultPhase = LifecyclePhase.INTEGRATION_TEST,
threadSafe = true)
public class IntegrationTestMojo extends AbstractSurefireMojo {
private static final String FAILSAFE_IN_PROGRESS_CONTEXT_KEY = "failsafe-in-progress";
/**
* The path representing project <em>JAR</em> file, if exists; Otherwise the directory containing generated
* classes of the project being tested. This will be included after the test classes in the test classpath.
* Defaults to built artifact <em>JAR</em> file or <code>${project.build.outputDirectory}</code>.
*/
@Parameter
private File classesDirectory;
@Parameter(defaultValue = "${project.build.outputDirectory}", readonly = true, required = true)
private File defaultClassesDirectory;
/**
* Set this to "true" to skip running integration tests, but still compile them. Its use is NOT RECOMMENDED, but
* quite convenient on occasion.
*
* @since 2.4.3-alpha-2
*/
@Parameter(property = "skipITs")
private boolean skipITs;
/**
* Base directory where all reports are written to.
*/
@Parameter(defaultValue = "${project.build.directory}/failsafe-reports")
private File reportsDirectory;
@SuppressWarnings("checkstyle:linelength")
/**
* Specify this parameter to run individual tests by file name, overriding parameter {@code includes} and
* {@code excludes}. Each pattern you specify here will be used to create an include pattern formatted like
* <code>**{@literal /}${it.test}.java</code>, so you can just type {@code -Dit.test=MyIT} to run
* a single test file called "foo/MyIT.java". The test patterns prefixed with a <em>!</em> will be excluded.
* <br>
* This parameter overrides the parameter {@code includes} and {@code excludes}, and the TestNG parameter
* {@code suiteXmlFiles}.
* <br>
* Since 2.7.3 You can execute a limited number of methods in the test with adding <i>#myMethod</i> or
* <i>#my*ethod</i>. E.g. type {@code -Dit.test=MyIT#myMethod} <b>supported for junit 4.x and TestNg.</b>
* <br>
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
* <pre><code>"-Dit.test=???IT, !Unstable*, pkg{@literal /}**{@literal /}Ci*leIT.java, *IT#test*One+testTwo?????, #fast*+slowTest"</code></pre>
* or e.g.
* <br>
* <pre><code>"-Dit.test=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyIT.class#one.*|two.*], %regex[#fast.*|slow.*]"</code></pre>
* <br>
* The Parameterized JUnit runner {@code describes} test methods using an index in brackets, so the non-regex
* method pattern would become: {@code #testMethod[*]}. If using <code>@Parameters(name="{index}: fib({0})={1}")</code>
* and selecting the index e.g. 5 in pattern, the non-regex method pattern would become {@code #testMethod[5:*]}.
*/
@Parameter(property = "it.test")
private String test;
/**
* The summary file to write integration test results to.
*/
@Parameter(defaultValue = "${project.build.directory}/failsafe-reports/failsafe-summary.xml", required = true)
private File summaryFile;
/**
* Option to print summary of test suites or just print the test cases that have errors.
*/
@Parameter(property = "failsafe.printSummary", defaultValue = "true")
private boolean printSummary;
/**
* Selects the formatting for the test report to be generated. Can be set as "brief" or "plain".
* Only applies to the output format of the output files (target/surefire-reports/testName.txt)
*/
@Parameter(property = "failsafe.reportFormat", defaultValue = "brief")
private String reportFormat;
/**
* Option to generate a file test report or just output the test report to the console.
*/
@Parameter(property = "failsafe.useFile", defaultValue = "true")
private boolean useFile;
/**
* Set this to "false" to prevent a failure if none of the tests specified in -Dit.test=... are run. Defaults to
* "true".
*
* @since 2.12
* @deprecated Since 3.0.0-M8, use "failsafe.failIfNoSpecifiedTests" instead.
*/
@Deprecated
@Parameter(property = "it.failIfNoSpecifiedTests", defaultValue = "true")
private boolean failIfNoSpecifiedTestsDeprecated;
/**
* Set this to "false" to prevent a failure if none of the tests specified in -Dit.test=... are run. Defaults to
* "true".
* Replacing "it.failIfNoSpecifiedTests" to be consistent with surefire plugin.
*
* @since 3.0.0-M8
*/
@Parameter(property = "failsafe.failIfNoSpecifiedTests", defaultValue = "true")
private boolean failIfNoSpecifiedTests;
/**
* Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach
* on port 5005. If set to some other string, that string will be appended to the argLine, allowing you to configure
* arbitrary debugging ability options (without overwriting the other options specified through the {@code argLine}
* parameter).
*
* @since 2.4
*/
@Parameter(property = "maven.failsafe.debug")
private String debugForkedProcess;
/**
* Kill the forked test process after a certain number of seconds. If set to 0, wait forever for the process, never
* timing out.
*
* @since 2.4
*/
@Parameter(property = "failsafe.timeout")
private int forkedProcessTimeoutInSeconds;
/**
* Forked process is normally terminated without any significant delay after given tests have completed.
* If the particular tests started non-daemon Thread(s), the process hangs instead of been properly terminated
* by {@code System.exit()}. Use this parameter in order to determine the timeout of terminating the process.
* <a href="http://maven.apache.org/surefire/maven-failsafe-plugin/examples/shutdown.html">see the documentation:
* http://maven.apache.org/surefire/maven-failsafe-plugin/examples/shutdown.html</a>
*
* @since 2.20
*/
@Parameter(property = "failsafe.exitTimeout", defaultValue = "30")
private int forkedProcessExitTimeoutInSeconds;
/**
* Stop executing queued parallel JUnit tests after a certain number of seconds.
* <br>
* Example values: "3.5", "4"<br>
* <br>
* If set to 0, wait forever, never timing out.
* Makes sense with specified {@code parallel} different from "none".
*
* @since 2.16
*/
@Parameter(property = "failsafe.parallel.timeout")
private double parallelTestsTimeoutInSeconds;
/**
* Stop executing queued parallel JUnit tests
* and <i>interrupt</i> currently running tests after a certain number of seconds.
* <br>
* Example values: "3.5", "4"<br>
* <br>
* If set to 0, wait forever, never timing out.
* Makes sense with specified {@code parallel} different from "none".
*
* @since 2.16
*/
@Parameter(property = "failsafe.parallel.forcedTimeout")
private double parallelTestsTimeoutForcedInSeconds;
@SuppressWarnings("checkstyle:linelength")
/**
* A list of {@literal <include>} elements specifying the test filter (by pattern) of tests which should be
* included in testing. If it is not specified and the {@code test} parameter is unspecified as well, the default
* includes is
* <pre><code>
* {@literal <includes>}
* {@literal <include>}**{@literal /}IT*.java{@literal </include>}
* {@literal <include>}**{@literal /}*IT.java{@literal </include>}
* {@literal <include>}**{@literal /}*ITCase.java{@literal </include>}
* {@literal </includes>}
* </code></pre>
* <br>
* Each include item may also contain a comma-separated sublist of items, which will be treated as multiple
* {@literal <include>} entries.<br>
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
* <pre><code>
* {@literal <include>}%regex[.*[Cat|Dog].*], Basic????, !Unstable*{@literal </include>}
* {@literal <include>}%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg{@literal /}**{@literal /}*Fast*.java{@literal </include>}
* </code></pre>
* <br>
* This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.<br>
* <br>
* <b>Notice that</b> these values are relative to the directory containing generated test classes of the project
* being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults
* to the POM property <code>${project.build.testOutputDirectory}</code>, typically
* <code>{@literal src/test/java}</code> unless overridden.
*/
@Parameter(property = "failsafe.includes")
// TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List<String> includes;
/**
* A list of {@literal <exclude>} elements specifying the tests (by pattern) that should be excluded in testing.
* When not specified and when the {@code test} parameter is not specified, the default excludes will be <br>
* <pre><code>
* {@literal <excludes>}
* {@literal <exclude>}**{@literal /}*$*{@literal </exclude>}
* {@literal </excludes>}
* </code></pre>
* (which excludes all inner classes).
* <br>
* This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
* <br>
* Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple
* {@literal <exclude>} entries.<br>
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
* <pre><code>
* {@literal <exclude>}%regex[pkg.*Slow.*.class], Unstable*{@literal </exclude>}
* </code></pre>
* <br>
* <b>Notice that</b> these values are relative to the directory containing generated test classes of the project
* being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults
* to the POM property <code>${project.build.testOutputDirectory}</code>, typically
* <code>{@literal src/test/java}</code> unless overridden.
*/
@Parameter(property = "failsafe.excludes")
// TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List<String> excludes;
/**
* Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking.
* Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's
* classloader.
*
* @since 2.3
*/
@Parameter(property = "failsafe.useSystemClassLoader", defaultValue = "true")
private boolean useSystemClassLoader;
/**
* By default, Surefire forks your tests using a manifest-only JAR; set this parameter to "false" to force it to
* launch your tests with a plain old Java classpath. (See the
* <a href="http://maven.apache.org/plugins/maven-failsafe-plugin/examples/class-loading.html">
* http://maven.apache.org/plugins/maven-failsafe-plugin/examples/class-loading.html</a>
* for a more detailed explanation of manifest-only JARs and their benefits.)
* <br>
* Beware, setting this to "false" may cause your tests to fail on Windows if your classpath is too long.
*
* @since 2.4.3
*/
@Parameter(property = "failsafe.useManifestOnlyJar", defaultValue = "true")
private boolean useManifestOnlyJar;
/**
* The character encoding scheme to be applied while generating test report
* files (see target/surefire-reports/yourTestName.txt).
* The report output files (*-out.txt) are still encoded with JVM's encoding used in standard out/err pipes.
*
* @since 3.0.0-M1
*/
@Parameter(property = "encoding", defaultValue = "${project.reporting.outputEncoding}")
private String encoding;
/**
* (JUnit 4+ providers and JUnit 5+ providers since 3.0.0-M4)
* The number of times each failing test will be rerun. If set larger than 0, rerun failing tests immediately after
* they fail. If a failing test passes in any of those reruns, it will be marked as pass and reported as a "flake".
* However, all the failing attempts will be recorded.
*/
@Parameter(property = "failsafe.rerunFailingTestsCount", defaultValue = "0")
private int rerunFailingTestsCount;
/**
* (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that
* {@code suiteXmlFiles} is incompatible with several other parameters of this plugin, like
* {@code includes} and {@code excludes}.<br>
* This parameter is ignored if the {@code test} parameter is specified (allowing you to run a single test
* instead of an entire suite).
*
* @since 2.2
*/
@Parameter(property = "failsafe.suiteXmlFiles")
private File[] suiteXmlFiles;
/**
* Defines the order the tests will be run in. Supported values are {@code alphabetical},
* {@code reversealphabetical}, {@code random}, {@code hourly} (alphabetical on even hours, reverse alphabetical
* on odd hours), {@code failedfirst}, {@code balanced} and {@code filesystem}.
* <br>
* <br>
* Odd/Even for hourly is determined at the time the of scanning the classpath, meaning it could change during a
* multi-module build.
* <br>
* <br>
* Failed first will run tests that failed on previous run first, as well as new tests for this run.
* <br>
* <br>
* Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests reducing the
* overall execution time. Initially a statistics file is created and every next test run will reorder classes.
* <br>
* <br>
* Note that the statistics are stored in a file named <b>.surefire-XXXXXXXXX</b> beside <i>pom.xml</i> and
* should not be checked into version control. The "XXXXX" is the SHA1 checksum of the entire surefire
* configuration, so different configurations will have different statistics files, meaning if you change any
* configuration settings you will re-run once before new statistics data can be established.
*
* @since 2.7
*/
@Parameter(property = "failsafe.runOrder", defaultValue = "filesystem")
private String runOrder;
/**
* Sets the random seed that will be used to order the tests if {@code failsafe.runOrder} is set to {@code random}.
* <br>
* <br>
* If no seeds are set and {@code failsafe.runOrder} is set to {@code random}, then the seed used will be
* outputted (search for "To reproduce ordering use flag -Dfailsafe.runOrder.random.seed").
* <br>
* <br>
* To deterministically reproduce any random test order that was run before, simply set the seed to
* be the same value.
*
* @since 3.0.0-M6
*/
@Parameter(property = "failsafe.runOrder.random.seed")
private Long runOrderRandomSeed;
/**
* A file containing include patterns, each in a next line. Blank lines, or lines starting with # are ignored.
* If {@code includes} are also specified, these patterns are appended. Example with path, simple and regex
* includes:
* <pre><code>
* *{@literal /}it{@literal /}*
* **{@literal /}NotIncludedByDefault.java
* %regex[.*IT.*|.*Not.*]
* </code></pre>
* <br>
* Since 3.0.0-M6, method filtering support is provided in the inclusions file as well, example:
* <pre><code>
* pkg.SomeIT#testMethod
* </code></pre>
*
* @since 2.13
*/
@Parameter(property = "failsafe.includesFile")
private File includesFile;
/**
* A file containing exclude patterns, each in a next line. Blank lines, or lines starting with # are ignored.
* If {@code excludes} are also specified, these patterns are appended.
* Example with path, simple and regex excludes:
* <pre><code>
* *{@literal /}it{@literal /}*
* **{@literal /}DontRunIT.*
* %regex[.*IT.*|.*Not.*]
* </code></pre>
* <br>
* Since 3.0.0-M6, method filtering support is provided in the exclusions file as well, example:
* <pre><code>
* pkg.SomeIT#testMethod
* </code></pre>
*
* @since 2.13
*/
@Parameter(property = "failsafe.excludesFile")
private File excludesFile;
/**
* Set to error/failure count in order to skip remaining tests.
* Due to race conditions in parallel/forked execution this may not be fully guaranteed.<br>
* Enable with system property {@code -Dfailsafe.skipAfterFailureCount=1} or any number greater than zero.
* Defaults to "0".<br>
* See the prerequisites and limitations in documentation:<br>
* <a href="http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html">
* http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html</a>
*
* @since 2.19
*/
@Parameter(property = "failsafe.skipAfterFailureCount", defaultValue = "0")
private int skipAfterFailureCount;
/**
* After the plugin process is shutdown by sending <i>SIGTERM signal (CTRL+C)</i>, <i>SHUTDOWN command</i> is
* received by every forked JVM.
* <br>
* The value is set to ({@code shutdown=exit}) by default (changed in version 3.0.0-M4).
* <br>
* The parameter can be configured with other two values {@code testset} and {@code kill}.
* <br>
* With({@code shutdown=testset}) the test set may still continue to run in forked JVM.
* <br>
* Using {@code exit} forked JVM executes {@code System.exit(1)} after the plugin process has received
* <i>SIGTERM signal</i>.
* <br>
* Using {@code kill} the JVM executes {@code Runtime.halt(1)} and kills itself.
*
* @since 2.19
*/
@Parameter(property = "failsafe.shutdown", defaultValue = "exit")
private String shutdown;
/**
* When {@code true}, uses the modulepath when executing with JDK 9+ and <i>module-info.java</i> is
* present. When {@code false}, always uses the classpath.
* <br>
* Defaults to {@code true}.
*
* @since 3.0.0-M2
*/
@Parameter(property = "failsafe.useModulePath", defaultValue = "true")
private boolean useModulePath;
/**
* This parameter configures the forked node. Currently, you can select the communication protocol, i.e. process
* pipes or TCP/IP sockets.
* The plugin uses process pipes by default which will be turned to TCP/IP in the version 3.0.0.
* Alternatively, you can implement your own factory and SPI.
* <br>
* See the documentation for more details:<br>
* <a href="https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html">
* https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html</a>
*
* @since 3.0.0-M5
*/
@Parameter(property = "failsafe.forkNode")
private ForkNodeFactory forkNode;
/**
* You can selectively exclude individual environment variables by enumerating their keys.
* <br>
* The environment is a system-dependent mapping from keys to values which is inherited from the Maven process
* to the forked Surefire processes. The keys must literally (case sensitive) match in order to exclude
* their environment variable.
* <br>
* Example to exclude three environment variables:
* <br>
* <i>mvn test -Dfailsafe.excludedEnvironmentVariables=ACME1,ACME2,ACME3</i>
*
* @since 3.0.0-M4
*/
@Parameter(property = "failsafe.excludedEnvironmentVariables")
private String[] excludedEnvironmentVariables;
/**
* Since 3.0.0-M4 the process checkers are disabled.
* You can enable them namely by setting {@code ping} and {@code native} or {@code all} in this parameter.
* <br>
* The checker is useful in situations when you kill the build on a CI system and you want the Surefire forked JVM
* to kill the tests asap and free all handlers on the file system been previously used by the JVM and by the tests.
*
* <br>
*
* The {@code ping} should be safely used together with ZGC or Shenandoah Garbage Collector.
* Due to the {@code ping} relies on timing of the PING (triggered every 30 seconds), slow GCs may pause
* the timers and pretend that the parent process of the forked JVM does not exist.
*
* <br>
*
* The {@code native} is very fast checker.
* It is useful mechanism on Unix based systems, Linux distributions and Alpine/BusyBox Linux.
* See the JIRA <a href="https://issues.apache.org/jira/browse/SUREFIRE-1631">SUREFIRE-1631</a> for Windows issues.
*
* <br>
*
* Another useful configuration parameter is {@code forkedProcessTimeoutInSeconds}.
* <br>
* See the Frequently Asked Questions page with more details:<br>
* <a href="http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm">
* http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm</a>
* <br>
* <a href="http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm">
* http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm</a>
*
* <br>
*
* Example of use:
* <br>
* <i>mvn test -Dfailsafe.enableProcessChecker=all</i>
*
* @since 3.0.0-M4
*/
@Parameter(property = "failsafe.enableProcessChecker")
private String enableProcessChecker;
/**
* Properties file being used as system properties passed to the provider.
*
* @see AbstractSurefireMojo#systemPropertyVariables {@code systemPropertyVariables} for how the effective provider properties are calculated
*/
@Parameter(property = "failsafe.systemPropertiesFile")
private File systemPropertiesFile;
/**
* Provide the ID/s of an JUnit engine to be included in the test run.
*
* @since 3.0.0-M6
*/
@Parameter(property = "failsafe.includeJUnit5Engines")
private String[] includeJUnit5Engines;
/**
* Provide the ID/s of an JUnit engine to be excluded in the test run.
*
* @since 3.0.0-M6
*/
@Parameter(property = "failsafe.excludeJUnit5Engines")
private String[] excludeJUnit5Engines;
@Override
protected int getRerunFailingTestsCount() {
return rerunFailingTestsCount;
}
@Override
@SuppressWarnings("unchecked")
protected void handleSummary(RunResult summary, Exception firstForkException)
throws MojoExecutionException, MojoFailureException {
try {
if (!summary.isNoTestsRun()) {
Object token = getPluginContext().get(FAILSAFE_IN_PROGRESS_CONTEXT_KEY);
writeSummary(summary, getSummaryFile(), token != null);
}
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
getPluginContext().put(FAILSAFE_IN_PROGRESS_CONTEXT_KEY, FAILSAFE_IN_PROGRESS_CONTEXT_KEY);
}
private boolean isJarArtifact(File artifactFile) {
return artifactFile != null
&& artifactFile.isFile()
&& artifactFile.getName().toLowerCase().endsWith(".jar");
}
private static File toAbsoluteCanonical(File f) {
try {
return f == null ? null : f.getAbsoluteFile().getCanonicalFile();
} catch (IOException e) {
throw new IllegalStateException(e.getLocalizedMessage(), e);
}
}
@Override
@SuppressWarnings("deprecation")
protected boolean isSkipExecution() {
return isSkip() || isSkipTests() || isSkipITs() || isSkipExec();
}
@Override
protected String getPluginName() {
return "failsafe";
}
@Override
protected String[] getDefaultIncludes() {
return new String[] {"**/IT*.java", "**/*IT.java", "**/*ITCase.java"};
}
@Override
protected String getReportSchemaLocation() {
return "https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report.xsd";
}
@Override
public boolean isSkipTests() {
return skipTests;
}
@Override
@Deprecated
public void setSkipTests(boolean skipTests) {
this.skipTests = skipTests;
}
public boolean isSkipITs() {
return skipITs;
}
public void setSkipITs(boolean skipITs) {
this.skipITs = skipITs;
}
@Override
@Deprecated
public boolean isSkipExec() {
return skipExec;
}
@Override
@Deprecated
public void setSkipExec(boolean skipExec) {
this.skipExec = skipExec;
}
@Override
public boolean isSkip() {
return skip;
}
@Override
public void setSkip(boolean skip) {
this.skip = skip;
}
@Override
public File getBasedir() {
return basedir;
}
@Override
public void setBasedir(File basedir) {
this.basedir = basedir;
}
@Override
public File getTestClassesDirectory() {
return testClassesDirectory;
}
@Override
public void setTestClassesDirectory(File testClassesDirectory) {
this.testClassesDirectory = testClassesDirectory;
}
/**
* @return Output directory, or artifact file if artifact type is "jar". If not forking the JVM, parameter
* {@link #useSystemClassLoader} is ignored and the {@link org.apache.maven.surefire.booter.IsolatedClassLoader} is
* used instead. See the resolution of {@link #getClassLoaderConfiguration() ClassLoaderConfiguration}.
*/
@Override
public File getMainBuildPath() {
File artifact = getProject().getArtifact().getFile();
boolean isDefaultClsDir = classesDirectory == null;
return isDefaultClsDir ? (isJarArtifact(artifact) ? artifact : defaultClassesDirectory) : classesDirectory;
}
@Override
public void setMainBuildPath(File mainBuildPath) {
classesDirectory = toAbsoluteCanonical(mainBuildPath);
}
public void setDefaultClassesDirectory(File defaultClassesDirectory) {
this.defaultClassesDirectory = toAbsoluteCanonical(defaultClassesDirectory);
}
@Override
public File getReportsDirectory() {
return reportsDirectory;
}
@Override
public void setReportsDirectory(File reportsDirectory) {
this.reportsDirectory = reportsDirectory;
}
@Override
public String getTest() {
return test;
}
@Override
public void setTest(String test) {
this.test = test;
}
public File getSummaryFile() {
return summaryFile;
}
public void setSummaryFile(File summaryFile) {
this.summaryFile = summaryFile;
}
@Override
public boolean isPrintSummary() {
return printSummary;
}
@Override
public void setPrintSummary(boolean printSummary) {
this.printSummary = printSummary;
}
@Override
public String getReportFormat() {
return reportFormat;
}
@Override
public void setReportFormat(String reportFormat) {
this.reportFormat = reportFormat;
}
@Override
public boolean isUseFile() {
return useFile;
}
@Override
public void setUseFile(boolean useFile) {
this.useFile = useFile;
}
@Override
public String getDebugForkedProcess() {
return debugForkedProcess;
}
@Override
public void setDebugForkedProcess(String debugForkedProcess) {
this.debugForkedProcess = debugForkedProcess;
}
@Override
public int getForkedProcessTimeoutInSeconds() {
return forkedProcessTimeoutInSeconds;
}
@Override
public void setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds) {
this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
}
@Override
public int getForkedProcessExitTimeoutInSeconds() {
return forkedProcessExitTimeoutInSeconds;
}
@Override
public void setForkedProcessExitTimeoutInSeconds(int forkedProcessExitTimeoutInSeconds) {
this.forkedProcessExitTimeoutInSeconds = forkedProcessExitTimeoutInSeconds;
}
@Override
public double getParallelTestsTimeoutInSeconds() {
return parallelTestsTimeoutInSeconds;
}
@Override
public void setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds) {
this.parallelTestsTimeoutInSeconds = parallelTestsTimeoutInSeconds;
}
@Override
public double getParallelTestsTimeoutForcedInSeconds() {
return parallelTestsTimeoutForcedInSeconds;
}
@Override
public void setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds) {
this.parallelTestsTimeoutForcedInSeconds = parallelTestsTimeoutForcedInSeconds;
}
@Override
public boolean isUseSystemClassLoader() {
return useSystemClassLoader;
}
@Override
public void setUseSystemClassLoader(boolean useSystemClassLoader) {
this.useSystemClassLoader = useSystemClassLoader;
}
@Override
public boolean isUseManifestOnlyJar() {
return useManifestOnlyJar;
}
@Override
public void setUseManifestOnlyJar(boolean useManifestOnlyJar) {
this.useManifestOnlyJar = useManifestOnlyJar;
}
@Override
public String getEncoding() {
return encoding;
}
@Override
public void setEncoding(String encoding) {
this.encoding = encoding;
}
// the following will be refactored out once the common code is all in one place
public boolean isTestFailureIgnore() {
return true; // ignore
}
public void setTestFailureIgnore(boolean testFailureIgnore) {
// ignore
}
@Override
protected void addPluginSpecificChecksumItems(ChecksumCalculator checksum) {
checksum.add(skipITs);
checksum.add(summaryFile);
}
@Override
public File getSystemPropertiesFile() {
return systemPropertiesFile;
}
@Override
public void setSystemPropertiesFile(File systemPropertiesFile) {
this.systemPropertiesFile = systemPropertiesFile;
}
@Override
@SuppressWarnings("deprecation")
public boolean getFailIfNoSpecifiedTests() {
if (!failIfNoSpecifiedTestsDeprecated) {
getConsoleLogger()
.warning("Use " + getPluginName()
+ ".failIfNoSpecifiedTests property instead of obsolete it.failIfNoSpecifiedTests.");
}
// since both have default "true", assuming that any "false" is set by user on purpose
return failIfNoSpecifiedTests && failIfNoSpecifiedTestsDeprecated;
}
@Override
public void setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests) {
this.failIfNoSpecifiedTests = failIfNoSpecifiedTests;
}
@Override
public int getSkipAfterFailureCount() {
return skipAfterFailureCount;
}
@Override
public String getShutdown() {
return shutdown;
}
@Override
public List<String> getIncludes() {
return includes;
}
@Override
public void setIncludes(List<String> includes) {
this.includes = includes;
}
@Override
public List<String> getExcludes() {
return excludes;
}
@Override
public void setExcludes(List<String> excludes) {
this.excludes = excludes;
}
@Override
public File[] getSuiteXmlFiles() {
return suiteXmlFiles.clone();
}
@Override
@SuppressWarnings("UnusedDeclaration")
public void setSuiteXmlFiles(File[] suiteXmlFiles) {
this.suiteXmlFiles = suiteXmlFiles.clone();
}
@Override
public String getRunOrder() {
return runOrder;
}
@Override
@SuppressWarnings("UnusedDeclaration")
public void setRunOrder(String runOrder) {
this.runOrder = runOrder;
}
@Override
public Long getRunOrderRandomSeed() {
return runOrderRandomSeed;
}
@Override
public void setRunOrderRandomSeed(Long runOrderRandomSeed) {
this.runOrderRandomSeed = runOrderRandomSeed;
}
@Override
public File getIncludesFile() {
return includesFile;
}
@Override
public File getExcludesFile() {
return excludesFile;
}
@Override
protected boolean useModulePath() {
return useModulePath;
}
@Override
protected void setUseModulePath(boolean useModulePath) {
this.useModulePath = useModulePath;
}
@Override
protected final List<File> suiteXmlFiles() {
return hasSuiteXmlFiles() ? Arrays.asList(suiteXmlFiles) : Collections.<File>emptyList();
}
@Override
protected final boolean hasSuiteXmlFiles() {
return suiteXmlFiles != null && suiteXmlFiles.length != 0;
}
@Override
protected final ForkNodeFactory getForkNode() {
return forkNode;
}
@Override
protected final String[] getExcludedEnvironmentVariables() {
return excludedEnvironmentVariables == null ? new String[0] : excludedEnvironmentVariables;
}
void setExcludedEnvironmentVariables(String[] excludedEnvironmentVariables) {
this.excludedEnvironmentVariables = excludedEnvironmentVariables;
}
@Override
protected final String getEnableProcessChecker() {
return enableProcessChecker;
}
public String[] getIncludeJUnit5Engines() {
return includeJUnit5Engines;
}
@SuppressWarnings("UnusedDeclaration")
public void setIncludeJUnit5Engines(String[] includeJUnit5Engines) {
this.includeJUnit5Engines = includeJUnit5Engines;
}
public String[] getExcludeJUnit5Engines() {
return excludeJUnit5Engines;
}
@SuppressWarnings("UnusedDeclaration")
public void setExcludeJUnit5Engines(String[] excludeJUnit5Engines) {
this.excludeJUnit5Engines = excludeJUnit5Engines;
}
}
|
googleapis/google-cloud-java | 36,283 | java-dialogflow/proto-google-cloud-dialogflow-v2beta1/src/main/java/com/google/cloud/dialogflow/v2beta1/ListDocumentsResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/dialogflow/v2beta1/document.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.dialogflow.v2beta1;
/**
*
*
* <pre>
* Response message for
* [Documents.ListDocuments][google.cloud.dialogflow.v2beta1.Documents.ListDocuments].
* </pre>
*
* Protobuf type {@code google.cloud.dialogflow.v2beta1.ListDocumentsResponse}
*/
public final class ListDocumentsResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.dialogflow.v2beta1.ListDocumentsResponse)
ListDocumentsResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListDocumentsResponse.newBuilder() to construct.
private ListDocumentsResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListDocumentsResponse() {
documents_ = java.util.Collections.emptyList();
nextPageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListDocumentsResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.dialogflow.v2beta1.DocumentProto
.internal_static_google_cloud_dialogflow_v2beta1_ListDocumentsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.dialogflow.v2beta1.DocumentProto
.internal_static_google_cloud_dialogflow_v2beta1_ListDocumentsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse.class,
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse.Builder.class);
}
public static final int DOCUMENTS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.dialogflow.v2beta1.Document> documents_;
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.dialogflow.v2beta1.Document> getDocumentsList() {
return documents_;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.cloud.dialogflow.v2beta1.DocumentOrBuilder>
getDocumentsOrBuilderList() {
return documents_;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
@java.lang.Override
public int getDocumentsCount() {
return documents_.size();
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
@java.lang.Override
public com.google.cloud.dialogflow.v2beta1.Document getDocuments(int index) {
return documents_.get(index);
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
@java.lang.Override
public com.google.cloud.dialogflow.v2beta1.DocumentOrBuilder getDocumentsOrBuilder(int index) {
return documents_.get(index);
}
public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Token to retrieve the next page of results, or empty if there are no
* more results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
@java.lang.Override
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
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();
nextPageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* Token to retrieve the next page of results, or empty if there are no
* more results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 {
for (int i = 0; i < documents_.size(); i++) {
output.writeMessage(1, documents_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < documents_.size(); i++) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, documents_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_);
}
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.dialogflow.v2beta1.ListDocumentsResponse)) {
return super.equals(obj);
}
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse other =
(com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse) obj;
if (!getDocumentsList().equals(other.getDocumentsList())) return false;
if (!getNextPageToken().equals(other.getNextPageToken())) 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 (getDocumentsCount() > 0) {
hash = (37 * hash) + DOCUMENTS_FIELD_NUMBER;
hash = (53 * hash) + getDocumentsList().hashCode();
}
hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getNextPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse 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.dialogflow.v2beta1.ListDocumentsResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse 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.dialogflow.v2beta1.ListDocumentsResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse 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.dialogflow.v2beta1.ListDocumentsResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse 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.dialogflow.v2beta1.ListDocumentsResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse 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.dialogflow.v2beta1.ListDocumentsResponse 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;
}
/**
*
*
* <pre>
* Response message for
* [Documents.ListDocuments][google.cloud.dialogflow.v2beta1.Documents.ListDocuments].
* </pre>
*
* Protobuf type {@code google.cloud.dialogflow.v2beta1.ListDocumentsResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.dialogflow.v2beta1.ListDocumentsResponse)
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.dialogflow.v2beta1.DocumentProto
.internal_static_google_cloud_dialogflow_v2beta1_ListDocumentsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.dialogflow.v2beta1.DocumentProto
.internal_static_google_cloud_dialogflow_v2beta1_ListDocumentsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse.class,
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse.Builder.class);
}
// Construct using com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (documentsBuilder_ == null) {
documents_ = java.util.Collections.emptyList();
} else {
documents_ = null;
documentsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
nextPageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.dialogflow.v2beta1.DocumentProto
.internal_static_google_cloud_dialogflow_v2beta1_ListDocumentsResponse_descriptor;
}
@java.lang.Override
public com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse getDefaultInstanceForType() {
return com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse build() {
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse buildPartial() {
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse result =
new com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse result) {
if (documentsBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
documents_ = java.util.Collections.unmodifiableList(documents_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.documents_ = documents_;
} else {
result.documents_ = documentsBuilder_.build();
}
}
private void buildPartial0(com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.nextPageToken_ = nextPageToken_;
}
}
@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.dialogflow.v2beta1.ListDocumentsResponse) {
return mergeFrom((com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse other) {
if (other == com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse.getDefaultInstance())
return this;
if (documentsBuilder_ == null) {
if (!other.documents_.isEmpty()) {
if (documents_.isEmpty()) {
documents_ = other.documents_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureDocumentsIsMutable();
documents_.addAll(other.documents_);
}
onChanged();
}
} else {
if (!other.documents_.isEmpty()) {
if (documentsBuilder_.isEmpty()) {
documentsBuilder_.dispose();
documentsBuilder_ = null;
documents_ = other.documents_;
bitField0_ = (bitField0_ & ~0x00000001);
documentsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getDocumentsFieldBuilder()
: null;
} else {
documentsBuilder_.addAllMessages(other.documents_);
}
}
}
if (!other.getNextPageToken().isEmpty()) {
nextPageToken_ = other.nextPageToken_;
bitField0_ |= 0x00000002;
onChanged();
}
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 10:
{
com.google.cloud.dialogflow.v2beta1.Document m =
input.readMessage(
com.google.cloud.dialogflow.v2beta1.Document.parser(), extensionRegistry);
if (documentsBuilder_ == null) {
ensureDocumentsIsMutable();
documents_.add(m);
} else {
documentsBuilder_.addMessage(m);
}
break;
} // case 10
case 18:
{
nextPageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
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.dialogflow.v2beta1.Document> documents_ =
java.util.Collections.emptyList();
private void ensureDocumentsIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
documents_ =
new java.util.ArrayList<com.google.cloud.dialogflow.v2beta1.Document>(documents_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.dialogflow.v2beta1.Document,
com.google.cloud.dialogflow.v2beta1.Document.Builder,
com.google.cloud.dialogflow.v2beta1.DocumentOrBuilder>
documentsBuilder_;
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public java.util.List<com.google.cloud.dialogflow.v2beta1.Document> getDocumentsList() {
if (documentsBuilder_ == null) {
return java.util.Collections.unmodifiableList(documents_);
} else {
return documentsBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public int getDocumentsCount() {
if (documentsBuilder_ == null) {
return documents_.size();
} else {
return documentsBuilder_.getCount();
}
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public com.google.cloud.dialogflow.v2beta1.Document getDocuments(int index) {
if (documentsBuilder_ == null) {
return documents_.get(index);
} else {
return documentsBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder setDocuments(int index, com.google.cloud.dialogflow.v2beta1.Document value) {
if (documentsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureDocumentsIsMutable();
documents_.set(index, value);
onChanged();
} else {
documentsBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder setDocuments(
int index, com.google.cloud.dialogflow.v2beta1.Document.Builder builderForValue) {
if (documentsBuilder_ == null) {
ensureDocumentsIsMutable();
documents_.set(index, builderForValue.build());
onChanged();
} else {
documentsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder addDocuments(com.google.cloud.dialogflow.v2beta1.Document value) {
if (documentsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureDocumentsIsMutable();
documents_.add(value);
onChanged();
} else {
documentsBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder addDocuments(int index, com.google.cloud.dialogflow.v2beta1.Document value) {
if (documentsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureDocumentsIsMutable();
documents_.add(index, value);
onChanged();
} else {
documentsBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder addDocuments(
com.google.cloud.dialogflow.v2beta1.Document.Builder builderForValue) {
if (documentsBuilder_ == null) {
ensureDocumentsIsMutable();
documents_.add(builderForValue.build());
onChanged();
} else {
documentsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder addDocuments(
int index, com.google.cloud.dialogflow.v2beta1.Document.Builder builderForValue) {
if (documentsBuilder_ == null) {
ensureDocumentsIsMutable();
documents_.add(index, builderForValue.build());
onChanged();
} else {
documentsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder addAllDocuments(
java.lang.Iterable<? extends com.google.cloud.dialogflow.v2beta1.Document> values) {
if (documentsBuilder_ == null) {
ensureDocumentsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, documents_);
onChanged();
} else {
documentsBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder clearDocuments() {
if (documentsBuilder_ == null) {
documents_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
documentsBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public Builder removeDocuments(int index) {
if (documentsBuilder_ == null) {
ensureDocumentsIsMutable();
documents_.remove(index);
onChanged();
} else {
documentsBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public com.google.cloud.dialogflow.v2beta1.Document.Builder getDocumentsBuilder(int index) {
return getDocumentsFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public com.google.cloud.dialogflow.v2beta1.DocumentOrBuilder getDocumentsOrBuilder(int index) {
if (documentsBuilder_ == null) {
return documents_.get(index);
} else {
return documentsBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public java.util.List<? extends com.google.cloud.dialogflow.v2beta1.DocumentOrBuilder>
getDocumentsOrBuilderList() {
if (documentsBuilder_ != null) {
return documentsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(documents_);
}
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public com.google.cloud.dialogflow.v2beta1.Document.Builder addDocumentsBuilder() {
return getDocumentsFieldBuilder()
.addBuilder(com.google.cloud.dialogflow.v2beta1.Document.getDefaultInstance());
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public com.google.cloud.dialogflow.v2beta1.Document.Builder addDocumentsBuilder(int index) {
return getDocumentsFieldBuilder()
.addBuilder(index, com.google.cloud.dialogflow.v2beta1.Document.getDefaultInstance());
}
/**
*
*
* <pre>
* The list of documents.
* </pre>
*
* <code>repeated .google.cloud.dialogflow.v2beta1.Document documents = 1;</code>
*/
public java.util.List<com.google.cloud.dialogflow.v2beta1.Document.Builder>
getDocumentsBuilderList() {
return getDocumentsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.dialogflow.v2beta1.Document,
com.google.cloud.dialogflow.v2beta1.Document.Builder,
com.google.cloud.dialogflow.v2beta1.DocumentOrBuilder>
getDocumentsFieldBuilder() {
if (documentsBuilder_ == null) {
documentsBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.dialogflow.v2beta1.Document,
com.google.cloud.dialogflow.v2beta1.Document.Builder,
com.google.cloud.dialogflow.v2beta1.DocumentOrBuilder>(
documents_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
documents_ = null;
}
return documentsBuilder_;
}
private java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Token to retrieve the next page of results, or empty if there are no
* more results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
nextPageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Token to retrieve the next page of results, or empty if there are no
* more results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Token to retrieve the next page of results, or empty if there are no
* more results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Token to retrieve the next page of results, or empty if there are no
* more results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearNextPageToken() {
nextPageToken_ = getDefaultInstance().getNextPageToken();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Token to retrieve the next page of results, or empty if there are no
* more results in the list.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The bytes for nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.dialogflow.v2beta1.ListDocumentsResponse)
}
// @@protoc_insertion_point(class_scope:google.cloud.dialogflow.v2beta1.ListDocumentsResponse)
private static final com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse();
}
public static com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListDocumentsResponse> PARSER =
new com.google.protobuf.AbstractParser<ListDocumentsResponse>() {
@java.lang.Override
public ListDocumentsResponse 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<ListDocumentsResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListDocumentsResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/tinkerpop | 36,604 | gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/NumberHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.tinkerpop.gremlin.util;
import org.apache.tinkerpop.gremlin.process.traversal.N;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.util.function.Function;
import java.util.function.BiFunction;
/**
* @author Daniel Kuppitz (http://gremlin.guru)
*/
public final class NumberHelper {
static final class NumberInfo {
private int bits;
private final boolean fp;
public int getBits() {
return bits;
}
public boolean getFp() {
return fp;
}
public void promoteBits() {
bits <<= 1;
}
NumberInfo(int bits, boolean fp) {
this.bits = bits;
this.fp = fp;
}
}
private static byte asByte(int arg) {
if (arg > Byte.MAX_VALUE || arg < Byte.MIN_VALUE)
throw new ArithmeticException("byte overflow");
return (byte) arg;
}
private static short asShort(int arg) {
if (arg > Short.MAX_VALUE || arg < Short.MIN_VALUE)
throw new ArithmeticException("short overflow");
return (short) arg;
}
static final NumberHelper BYTE_NUMBER_HELPER = new NumberHelper(
(a, b) -> asByte(a.byteValue() + b.byteValue()),
(a, b) -> asByte(a.byteValue() - b.byteValue()),
(a, b) -> asByte(a.byteValue() * b.byteValue()),
(a, b) -> {
if (a.byteValue() == Byte.MIN_VALUE && b.byteValue() == -1) {
throw new ArithmeticException("byte overflow");
}
return (byte)(a.byteValue() / b.byteValue());
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final byte x = a.byteValue(), y = b.byteValue();
return x <= y ? x : y;
}
return a.byteValue();
}
return b.byteValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final byte x = a.byteValue(), y = b.byteValue();
return x >= y ? x : y;
}
return a.byteValue();
}
return b.byteValue();
},
(a, b) -> Byte.compare(a.byteValue(), b.byteValue()));
static final NumberHelper SHORT_NUMBER_HELPER = new NumberHelper(
(a, b) -> asShort(a.shortValue() + b.shortValue()),
(a, b) -> asShort(a.shortValue() - b.shortValue()),
(a, b) -> asShort(a.shortValue() * b.shortValue()),
(a, b) -> {
if (a.shortValue() == Short.MIN_VALUE && b.shortValue() == -1) {
throw new ArithmeticException("short overflow");
}
return (short)(a.shortValue() / b.shortValue());
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final short x = a.shortValue(), y = b.shortValue();
return x <= y ? x : y;
}
return a.shortValue();
}
return b.shortValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final short x = a.shortValue(), y = b.shortValue();
return x >= y ? x : y;
}
return a.shortValue();
}
return b.shortValue();
},
(a, b) -> Short.compare(a.shortValue(), b.shortValue()));
static final NumberHelper INTEGER_NUMBER_HELPER = new NumberHelper(
(a, b) -> Math.addExact(a.intValue(), b.intValue()),
(a, b) -> Math.subtractExact(a.intValue(), b.intValue()),
(a, b) -> Math.multiplyExact(a.intValue(), b.intValue()),
(a, b) -> {
if (a.intValue() == Integer.MIN_VALUE && b.intValue() == -1) {
throw new ArithmeticException("integer overflow");
}
return a.intValue() / b.intValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final int x = a.intValue(), y = b.intValue();
return x <= y ? x : y;
}
return a.intValue();
}
return b.intValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final int x = a.intValue(), y = b.intValue();
return x >= y ? x : y;
}
return a.intValue();
}
return b.intValue();
},
(a, b) -> Integer.compare(a.intValue(), b.intValue()));
static final NumberHelper LONG_NUMBER_HELPER = new NumberHelper(
(a, b) -> Math.addExact(a.longValue(), b.longValue()),
(a, b) -> Math.subtractExact(a.longValue(), b.longValue()),
(a, b) -> Math.multiplyExact(a.longValue(), b.longValue()),
(a, b) -> {
if (a.longValue() == Long.MIN_VALUE && b.longValue() == -1) {
throw new ArithmeticException("long overflow");
}
return a.longValue() / b.longValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final long x = a.longValue(), y = b.longValue();
return x <= y ? x : y;
}
return a.longValue();
}
return b.longValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final long x = a.longValue(), y = b.longValue();
return x >= y ? x : y;
}
return a.longValue();
}
return b.longValue();
},
(a, b) -> Long.compare(a.longValue(), b.longValue()));
static final NumberHelper BIG_INTEGER_NUMBER_HELPER = new NumberHelper(
(a, b) -> bigIntegerValue(a).add(bigIntegerValue(b)),
(a, b) -> bigIntegerValue(a).subtract(bigIntegerValue(b)),
(a, b) -> bigIntegerValue(a).multiply(bigIntegerValue(b)),
(a, b) -> bigIntegerValue(a).divide(bigIntegerValue(b)),
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final BigInteger x = bigIntegerValue(a), y = bigIntegerValue(b);
return x.compareTo(y) <= 0 ? x : y;
}
return bigIntegerValue(a);
}
return bigIntegerValue(b);
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final BigInteger x = bigIntegerValue(a), y = bigIntegerValue(b);
return x.compareTo(y) >= 0 ? x : y;
}
return bigIntegerValue(a);
}
return bigIntegerValue(b);
},
(a, b) -> bigIntegerValue(a).compareTo(bigIntegerValue(b)));
static final NumberHelper FLOAT_NUMBER_HELPER = new NumberHelper(
(a, b) -> a.floatValue() + b.floatValue(),
(a, b) -> a.floatValue() - b.floatValue(),
(a, b) -> a.floatValue() * b.floatValue(),
(a, b) -> a.floatValue() / b.floatValue(),
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final float x = a.floatValue(), y = b.floatValue();
return x <= y ? x : y;
}
return a.floatValue();
}
return b.floatValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final float x = a.floatValue(), y = b.floatValue();
return x >= y ? x : y;
}
return a.floatValue();
}
return b.floatValue();
},
(a, b) -> Float.compare(a.floatValue(), b.floatValue()));
static final NumberHelper DOUBLE_NUMBER_HELPER = new NumberHelper(
(a, b) -> a.doubleValue() + b.doubleValue(),
(a, b) -> a.doubleValue() - b.doubleValue(),
(a, b) -> a.doubleValue() * b.doubleValue(),
(a, b) -> a.doubleValue() / b.doubleValue(),
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final double x = a.doubleValue(), y = b.doubleValue();
return x <= y ? x : y;
}
return a.doubleValue();
}
return b.doubleValue();
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final double x = a.doubleValue(), y = b.doubleValue();
return x >= y ? x : y;
}
return a.doubleValue();
}
return b.doubleValue();
},
(a, b) -> Double.compare(a.doubleValue(), b.doubleValue()));
static final NumberHelper BIG_DECIMAL_NUMBER_HELPER = new NumberHelper(
(a, b) -> bigDecimalValue(a).add(bigDecimalValue(b)),
(a, b) -> bigDecimalValue(a).subtract(bigDecimalValue(b)),
(a, b) -> bigDecimalValue(a).multiply(bigDecimalValue(b)),
(a, b) -> {
final BigDecimal ba = bigDecimalValue(a);
final BigDecimal bb = bigDecimalValue(b);
try {
return ba.divide(bb);
} catch (ArithmeticException ignored) {
// set a default precision
final int precision = Math.max(ba.precision(), bb.precision()) + 10;
BigDecimal result = ba.divide(bb, new MathContext(precision));
final int scale = Math.max(Math.max(ba.scale(), bb.scale()), 10);
if (result.scale() > scale) result = result.setScale(scale, BigDecimal.ROUND_HALF_UP);
return result;
}
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final BigDecimal x = bigDecimalValue(a), y = bigDecimalValue(b);
return x.compareTo(y) <= 0 ? x : y;
}
return bigDecimalValue(a);
}
return bigDecimalValue(b);
},
(a, b) -> {
if (isNumber(a)) {
if (isNumber(b)) {
final BigDecimal x = bigDecimalValue(a), y = bigDecimalValue(b);
return x.compareTo(y) >= 0 ? x : y;
}
return bigDecimalValue(a);
}
return bigDecimalValue(b);
},
(a, b) -> {
if( a instanceof Float && ((Float) a) == Float.POSITIVE_INFINITY)
return 1;
else if( a instanceof Float && ((Float) a) == Float.NEGATIVE_INFINITY)
return -1;
else if( b instanceof Float && ((Float) b) == Float.POSITIVE_INFINITY)
return -1;
else if( b instanceof Float && ((Float) b) == Float.NEGATIVE_INFINITY)
return 1;
else if( a instanceof Double && ((Double) a) == Double.POSITIVE_INFINITY)
return 1;
else if( a instanceof Double && ((Double) a) == Double.NEGATIVE_INFINITY)
return -1;
else if( b instanceof Double && ((Double) b) == Double.POSITIVE_INFINITY)
return -1;
else if( b instanceof Double && ((Double) b) == Double.NEGATIVE_INFINITY)
return 1;
return bigDecimalValue(a).compareTo(bigDecimalValue(b));
});
public final BiFunction<Number, Number, Number> add;
public final BiFunction<Number, Number, Number> sub;
public final BiFunction<Number, Number, Number> mul;
public final BiFunction<Number, Number, Number> div;
public final BiFunction<Number, Number, Number> min;
public final BiFunction<Number, Number, Number> max;
public final BiFunction<Number, Number, Integer> cmp;
private NumberHelper(final BiFunction<Number, Number, Number> add,
final BiFunction<Number, Number, Number> sub,
final BiFunction<Number, Number, Number> mul,
final BiFunction<Number, Number, Number> div,
final BiFunction<Number, Number, Number> min,
final BiFunction<Number, Number, Number> max,
final BiFunction<Number, Number, Integer> cmp
) {
this.add = add;
this.sub = sub;
this.mul = mul;
this.div = div;
this.min = min;
this.max = max;
this.cmp = cmp;
}
static NumberInfo getHighestCommonNumberInfo(final boolean forceFloatingPoint, final Number... numbers) {
int bits = 8;
boolean fp = forceFloatingPoint;
for (final Number number : numbers) {
if (!isNumber(number)) continue;
final Class<? extends Number> clazz = number.getClass();
if (clazz.equals(Byte.class)) continue;
if (clazz.equals(Short.class)) {
bits = Math.max(bits, 16);
} else if (clazz.equals(Integer.class)) {
bits = Math.max(bits, 32);
} else if (clazz.equals(Long.class)) {
bits = Math.max(bits, 64);
} else if (clazz.equals(BigInteger.class)) {
bits = 128;
} else if (clazz.equals(Float.class)) {
bits = Math.max(bits, 32);
fp = true;
} else if (clazz.equals(Double.class)) {
bits = Math.max(bits, 64);
fp = true;
} else /*if (clazz.equals(BigDecimal.class))*/ {
bits = 128;
fp = true;
break; // maxed out, no need to check remaining numbers
}
}
return new NumberInfo(bits, fp);
}
public static Class<? extends Number> getHighestCommonNumberClass(final Number... numbers) {
return getHighestCommonNumberClass(false, numbers);
}
public static Class<? extends Number> getHighestCommonNumberClass(final boolean forceFloatingPoint, final Number... numbers) {
NumberInfo numberInfo = getHighestCommonNumberInfo(forceFloatingPoint, numbers);
return determineNumberClass(numberInfo.getBits(), numberInfo.getFp());
}
private static Number mathOperationWithPromote(final Function<NumberHelper, BiFunction<Number, Number, Number>> mathFunction, final boolean forceFloatingPoint, final Number a, final Number b) {
if (null == a || null == b) return a;
NumberInfo numberInfo = getHighestCommonNumberInfo(forceFloatingPoint, a, b);
Number result = 0;
while (true) {
try {
final Class<? extends Number> clazz = determineNumberClass(numberInfo.getBits(), numberInfo.getFp());
final NumberHelper helper = getHelper(clazz);
result = mathFunction.apply(helper).apply(a, b);
if (result instanceof BigInteger || result instanceof BigDecimal)
{
return result;
}
if (Double.isInfinite(result.doubleValue()))
{
throw new ArithmeticException("Floating point overflow detected");
}
return result;
} catch (ArithmeticException exception) {
if (!numberInfo.getFp() && numberInfo.getBits() >= 64) {
throw exception;
} else if (numberInfo.getFp() && numberInfo.getBits() >= 64) {
return result;
}
numberInfo.promoteBits();
}
}
}
/**
* Adds two numbers returning the highest common number class between them.
*
* <p>
* This method returns a result using the highest common number class between the two inputs.
* If an overflow occurs (either integer or floating-point), the method promotes the precision
* by increasing the bit width, until a suitable type is found.
* If no suitable type exists (e.g., for very large integers beyond 64-bit),
* an {@link ArithmeticException} is thrown. For floating-point numbers, if {@code double} overflows,
* the result is {@code Double.POSITIVE_INFINITY} or {@code Double.NEGATIVE_INFINITY} instead of an exception.
* </p>
*
* <pre>
* a = 1, b = 1 -> 2
* a = null, b = 1 -> null
* a = 1, b = null -> 1
* a = null, b = null -> null
* </pre>
*
* @param a should be thought of as the seed to be modified by {@code b}
* @param b the modifier to {code a}
*/
public static Number add(final Number a, final Number b) {
return mathOperationWithPromote(numberHelper -> numberHelper.add, false, a, b);
}
/**
* Subtracts two numbers returning the highest common number class between them.
*
* <p>
* This method returns a result using the highest common number class between the two inputs.
* If an overflow occurs (either integer or floating-point), the method promotes the precision
* by increasing the bit width, until a suitable type is found.
* If no suitable type exists (e.g., for very large integers beyond 64-bit),
* an {@link ArithmeticException} is thrown. For floating-point numbers, if {@code double} overflows,
* the result is {@code Double.POSITIVE_INFINITY} or {@code Double.NEGATIVE_INFINITY} instead of an exception.
* </p>
*
* <pre>
* a = 1, b = 1 -> 0
* a = null, b = 1 -> null
* a = 1, b = null -> 1
* a = null, b = null -> null
* </pre>
*
* @param a should be thought of as the seed to be modified by {@code b}
* @param b the modifier to {code a}
*/
public static Number sub(final Number a, final Number b) {
return mathOperationWithPromote(numberHelper -> numberHelper.sub, false, a, b);
}
/**
* Multiplies two numbers returning the highest common number class between them.
*
* <p>
* This method returns a result using the highest common number class between the two inputs.
* If an overflow occurs (either integer or floating-point), the method promotes the precision
* by increasing the bit width, until a suitable type is found.
* If no suitable type exists (e.g., for very large integers beyond 64-bit),
* an {@link ArithmeticException} is thrown. For floating-point numbers, if {@code double} overflows,
* the result is {@code Double.POSITIVE_INFINITY} or {@code Double.NEGATIVE_INFINITY} instead of an exception.
* </p>
*
* <pre>
* a = 1, b = 2 -> 2
* a = null, b = 1 -> null
* a = 1, b = null -> 1
* a = null, b = null -> null
* </pre>
*
* @param a should be thought of as the seed to be modified by {@code b}
* @param b the modifier to {code a}
*/
public static Number mul(final Number a, final Number b) {
return mathOperationWithPromote(numberHelper -> numberHelper.mul, false, a, b);
}
/**
* Divides two numbers returning the highest common number class between them calling
* {@link #div(Number, Number, boolean)} with a {@code false}.
*/
public static Number div(final Number a, final Number b) {
return mathOperationWithPromote(numberHelper -> numberHelper.div, false, a, b);
}
/**
* Divides two numbers returning the highest common number class between them.
*
* <p>
* This method returns a result using the highest common number class between the two inputs.
* If an overflow occurs (either integer or floating-point), the method promotes the precision
* by increasing the bit width, until a suitable type is found.
* If no suitable type exists (e.g., for very large integers beyond 64-bit),
* an {@link ArithmeticException} is thrown. For floating-point numbers, if {@code double} overflows,
* the result is {@code Double.POSITIVE_INFINITY} or {@code Double.NEGATIVE_INFINITY} instead of an exception.
* </p>
*
* <pre>
* a = 4, b = 2 -> 2
* a = null, b = 1 -> null
* a = 1, b = null -> 1
* a = null, b = null -> null
* </pre>
*
* @param a should be thought of as the seed to be modified by {@code b}
* @param b the modifier to {code a}
* @param forceFloatingPoint when set to {@code true} ensures that the return value is the highest common floating number class
*/
public static Number div(final Number a, final Number b, final boolean forceFloatingPoint) {
return mathOperationWithPromote(numberHelper -> numberHelper.div, forceFloatingPoint, a, b);
}
/**
* Gets the smaller number of the two provided returning the highest common number class between them.
*
* <pre>
* a = 4, b = 2 -> 2
* a = null, b = 1 -> 1
* a = 1, b = null -> 1
* a = null, b = null -> null
* a = NaN, b = 1 -> 1
* a = 1, b = NaN -> 1
* a = NaN, b = NaN -> NaN
* </pre>
*/
public static Number min(final Number a, final Number b) {
// handle one or both null (propagate null if both)
if (a == null || b == null)
return a == null ? b : a;
// handle one or both NaN (propagate NaN if both)
if (eitherAreNaN(a, b))
return isNaN(a) ? b : a;
final Class<? extends Number> clazz = getHighestCommonNumberClass(a, b);
return getHelper(clazz).min.apply(a, b);
}
/**
* Gets the smaller number of the two provided returning the highest common number class between them.
*
* <pre>
* a = 4, b = 2 -> 2
* a = null, b = 1 -> 1
* a = 1, b = null -> 1
* a = null, b = null -> null
* a = NaN, b = 1 -> 1
* a = 1, b = NaN -> 1
* a = NaN, b = NaN -> NaN
* </pre>
*/
public static Comparable min(final Comparable a, final Comparable b) {
// handle one or both null (propagate null if both)
if (a == null || b == null)
return a == null ? b : a;
// handle one or both NaN (propagate NaN if both)
if (eitherAreNaN(a, b))
return isNaN(a) ? b : a;
if (a instanceof Number && b instanceof Number) {
final Number an = (Number) a, bn = (Number) b;
final Class<? extends Number> clazz = getHighestCommonNumberClass(an, bn);
return (Comparable) getHelper(clazz).min.apply(an, bn);
} else {
return a.compareTo(b) < 0 ? a : b;
}
}
/**
* Gets the larger number of the two provided returning the highest common number class between them.
*
* <pre>
* a = 4, b = 2 -> 4
* a = null, b = 1 -> 1
* a = 1, b = null -> 1
* a = null, b = null -> null
* a = NaN, b = 1 -> 1
* a = 1, b = NaN -> 1
* a = NaN, b = NaN -> NaN
* </pre>
*/
public static Number max(final Number a, final Number b) {
// handle one or both null (propagate null if both)
if (a == null || b == null)
return a == null ? b : a;
// handle one or both NaN (propagate NaN if both)
if (eitherAreNaN(a, b))
return isNaN(a) ? b : a;
final Class<? extends Number> clazz = getHighestCommonNumberClass(a, b);
return getHelper(clazz).max.apply(a, b);
}
/**
* Gets the larger number of the two provided returning the highest common number class between them.
*
* <pre>
* a = 4, b = 2 -> 4
* a = null, b = 1 -> 1
* a = 1, b = null -> 1
* a = null, b = null -> null
* a = NaN, b = 1 -> 1
* a = 1, b = NaN -> 1
* a = NaN, b = NaN -> NaN
* </pre>
*/
public static Comparable max(final Comparable a, final Comparable b) {
// handle one or both null (propagate null if both)
if (a == null || b == null)
return a == null ? b : a;
// handle one or both NaN (propagate NaN if both)
if (eitherAreNaN(a, b))
return isNaN(a) ? b : a;
if (a instanceof Number && b instanceof Number) {
final Number an = (Number) a, bn = (Number) b;
final Class<? extends Number> clazz = getHighestCommonNumberClass(an, bn);
return (Comparable) getHelper(clazz).max.apply(an, bn);
} else {
return a.compareTo(b) > 0 ? a : b;
}
}
/**
* Compares two numbers. Follows orderability semantics for NaN, which places NaN after +Inf.
*
* <pre>
* a = 4, b = 2 -> 1
* a = 2, b = 4 -> -1
* a = null, b = 1 -> -1
* a = 1, b = null -> 1
* a = null, b = null -> 0
* a = NaN, b = NaN -> 0
* a = NaN, b = Inf -> 1
* </pre>
*/
public static Integer compare(final Number a, final Number b) {
// handle one or both null
if (a == null || b == null)
return a == b ? 0 : (a == null ? -1 : 1);
// handle one or both NaN
if (eitherAreNaN(a, b))
return (bothAreNaN(a, b)) ? 0 : isNaN(a) ? 1 : -1;
final Class<? extends Number> clazz = getHighestCommonNumberClass(a, b);
return getHelper(clazz).cmp.apply(a, b);
}
/**
* Coerces the given number to the specified numeric type if it can fit into it.
* Otherwise, retains the original type.
*
* @param a the number to be coerced
* @param clazz the target numeric type class
* @return the coerced number in the specified type or the original type if it cannot fit
* @throws IllegalArgumentException if the specified numeric type is unsupported
*/
public static Number coerceTo(final Number a, final Class<? extends Number> clazz) {
try {
return performConversion(a, clazz);
} catch (ArithmeticException e) {
// return as-is since it didn't fit the type we wanted to coerce to
return a;
}
}
/**
* Casts the given number to the specified numeric type if it can fit into it.
* Otherwise, throw.
*
* @param a the number to be cast
* @param numberToken the number token denoting the desired type to cast
* @return the number cast to the specified type
* @throws IllegalArgumentException if the specified numeric type is unsupported
* @throws ArithmeticException if the number overflows
*/
public static Number castTo(final Number a, final N numberToken) {
Class<? extends Number> clazz = numberToken.getType();
return performConversion(a, clazz);
}
/**
* Core conversion logic.
* Throws ArithmeticException when conversion would overflow.
*/
private static Number performConversion(final Number a, final Class<? extends Number> clazz) {
if (a.getClass().equals(clazz)) {
return a;
}
if (clazz.equals(Integer.class)) {
Long val = longValue(a, clazz);
if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) {
return a.intValue();
}
} else if (clazz.equals(Long.class)) {
return longValue(a, clazz);
} else if (clazz.equals(Float.class)) {
// BigDecimal or BigInteger to double can overflow into Infinity, we want to prevent this
if (isInfinityOrNaN(a)) {
return a.floatValue();
}
if (a.doubleValue() >= -Float.MAX_VALUE && a.doubleValue() <= Float.MAX_VALUE) {
return a.floatValue();
}
} else if (clazz.equals(Double.class)) {
// BigDecimal or BigInteger to double can overflow into Infinity, we want to prevent this
if (isInfinityOrNaN(a)) {
return a.doubleValue();
}
if (!Double.isInfinite(a.doubleValue())) {
// float losses precision, use string intermediate
return a.getClass().equals(Float.class) ? Double.parseDouble(a.toString()) : a.doubleValue();
}
} else if (clazz.equals(Byte.class)) {
Long val = longValue(a, clazz);
if (val >= Byte.MIN_VALUE && val <= Byte.MAX_VALUE) {
return a.byteValue();
}
} else if (clazz.equals(Short.class)) {
Long val = longValue(a, clazz);
if (val >= Short.MIN_VALUE && val <= Short.MAX_VALUE) {
return a.shortValue();
}
} else if (clazz.equals(BigInteger.class)) {
return NumberHelper.bigIntegerValue(a);
} else if (clazz.equals(BigDecimal.class)) {
return NumberHelper.bigDecimalValue(a);
} else {
throw new IllegalArgumentException("Unsupported numeric type: " + clazz);
}
throw new ArithmeticException(String.format("Can't convert number of type %s to %s due to overflow.",
a.getClass().getSimpleName(), clazz.getSimpleName()));
}
private static Long longValue(final Number num, final Class<? extends Number> targetClass) {
// Explicitly throw when converting floating point infinity and NaN to whole numbers
if (Double.isNaN(num.doubleValue())) {
throw new ArithmeticException(String.format("Can't convert NaN to %s.", targetClass.getSimpleName()));
}
if (Double.isInfinite(num.doubleValue())) {
throw new ArithmeticException(String.format("Can't convert floating point infinity to %s.", targetClass.getSimpleName()));
}
String msgOverflow = String.format("Can't convert number of type %s to %s due to overflow.",
num.getClass().getSimpleName(), targetClass.getSimpleName());
if (num.getClass().equals(Double.class) || num.getClass().equals(Float.class)) {
double value = num.doubleValue();
if (value > Long.MAX_VALUE) {
throw new ArithmeticException(msgOverflow);
}
if (value < Long.MIN_VALUE) {
throw new ArithmeticException(String.format("Can't convert number of type %s to %s due to underflow.",
num.getClass().getSimpleName(), targetClass.getSimpleName()));
}
}
try {
if (num.getClass().equals(BigDecimal.class)) return ((BigDecimal) num).longValueExact();
return num.getClass().equals(BigInteger.class) ? ((BigInteger) num).longValueExact() : num.longValue();
} catch (ArithmeticException ae) {
throw new ArithmeticException(msgOverflow);
}
}
private static boolean isInfinityOrNaN(Number num) {
return (!num.getClass().equals(BigDecimal.class) && !num.getClass().equals(BigInteger.class) &&
(Double.isInfinite(num.doubleValue()) || Double.isNaN(num.doubleValue())));
}
private static NumberHelper getHelper(final Class<? extends Number> clazz) {
if (clazz.equals(Byte.class)) {
return BYTE_NUMBER_HELPER;
}
if (clazz.equals(Short.class)) {
return SHORT_NUMBER_HELPER;
}
if (clazz.equals(Integer.class)) {
return INTEGER_NUMBER_HELPER;
}
if (clazz.equals(Long.class)) {
return LONG_NUMBER_HELPER;
}
if (clazz.equals(BigInteger.class)) {
return BIG_INTEGER_NUMBER_HELPER;
}
if (clazz.equals(Float.class)) {
return FLOAT_NUMBER_HELPER;
}
if (clazz.equals(Double.class)) {
return DOUBLE_NUMBER_HELPER;
}
if (clazz.equals(BigDecimal.class)) {
return BIG_DECIMAL_NUMBER_HELPER;
}
throw new IllegalArgumentException("Unsupported numeric type: " + clazz);
}
private static BigInteger bigIntegerValue(final Number number) {
if (number == null) return null;
if (number instanceof BigInteger) return (BigInteger) number;
if (number instanceof BigDecimal) return ((BigDecimal) number).toBigInteger();
if (number instanceof Double) return BigDecimal.valueOf(number.doubleValue()).toBigInteger();
return BigInteger.valueOf(number.longValue());
}
private static BigDecimal bigDecimalValue(final Number number) {
if (number == null) return null;
if (number instanceof BigDecimal) return (BigDecimal) number;
if (number instanceof BigInteger) return new BigDecimal((BigInteger) number);
if (number instanceof Float) return new BigDecimal(number.toString()); // float losses precision, use string intermediate
return (number instanceof Double)
? BigDecimal.valueOf(number.doubleValue())
: BigDecimal.valueOf(number.longValue());
}
private static Class<? extends Number> determineNumberClass(final int bits, final boolean floatingPoint) {
if (floatingPoint) {
if (bits <= 32) return Float.class;
if (bits <= 64) return Double.class;
return BigDecimal.class;
} else {
if (bits <= 8) return Byte.class;
if (bits <= 16) return Short.class;
if (bits <= 32) return Integer.class;
if (bits <= 64) return Long.class;
return BigInteger.class;
}
}
private static boolean isNumber(final Number number) {
return number != null && !isNaN(number);
}
public static boolean isNaN(final Object object) {
return (object instanceof Float && Float.isNaN((float) object)) ||
(object instanceof Double && Double.isNaN((double) object));
}
public static boolean eitherAreNaN(final Object first, final Object second) {
return isNaN(first) || isNaN(second);
}
public static boolean bothAreNaN(final Object first, final Object second) {
return isNaN(first) && isNaN(second);
}
public static boolean isPositiveInfinity(final Object value) {
return (value instanceof Float && Float.POSITIVE_INFINITY == ((float) value)) ||
(value instanceof Double && Double.POSITIVE_INFINITY == ((double) value));
}
public static boolean isNegativeInfinity(final Object value) {
return (value instanceof Float && Float.NEGATIVE_INFINITY == ((float) value)) ||
(value instanceof Double && Double.NEGATIVE_INFINITY == ((double) value));
}
}
|
apache/ignite-3 | 36,578 | modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ignite.internal.client.table;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static org.apache.ignite.internal.client.proto.ProtocolBitmaskFeature.TX_DELAYED_ACKS;
import static org.apache.ignite.internal.client.proto.ProtocolBitmaskFeature.TX_DIRECT_MAPPING;
import static org.apache.ignite.internal.client.proto.ProtocolBitmaskFeature.TX_PIGGYBACK;
import static org.apache.ignite.internal.util.ExceptionUtils.sneakyThrow;
import static org.apache.ignite.internal.util.ExceptionUtils.unwrapCause;
import static org.apache.ignite.lang.ErrorGroups.Common.INTERNAL_ERR;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.apache.ignite.client.RetryPolicy;
import org.apache.ignite.internal.client.ClientSchemaVersionMismatchException;
import org.apache.ignite.internal.client.ClientUtils;
import org.apache.ignite.internal.client.PartitionMapping;
import org.apache.ignite.internal.client.PayloadInputChannel;
import org.apache.ignite.internal.client.PayloadOutputChannel;
import org.apache.ignite.internal.client.ReliableChannel;
import org.apache.ignite.internal.client.WriteContext;
import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
import org.apache.ignite.internal.client.proto.ClientOp;
import org.apache.ignite.internal.client.proto.ColumnTypeConverter;
import org.apache.ignite.internal.client.sql.ClientSql;
import org.apache.ignite.internal.client.table.api.PublicApiClientKeyValueView;
import org.apache.ignite.internal.client.table.api.PublicApiClientRecordView;
import org.apache.ignite.internal.client.tx.ClientTransaction;
import org.apache.ignite.internal.client.tx.DirectTxUtils;
import org.apache.ignite.internal.hlc.HybridTimestamp;
import org.apache.ignite.internal.lang.IgniteBiTuple;
import org.apache.ignite.internal.lang.IgniteTriConsumer;
import org.apache.ignite.internal.logger.IgniteLogger;
import org.apache.ignite.internal.marshaller.MarshallersProvider;
import org.apache.ignite.internal.marshaller.UnmappedColumnsException;
import org.apache.ignite.internal.tostring.IgniteToStringBuilder;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.table.KeyValueView;
import org.apache.ignite.table.QualifiedName;
import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
import org.apache.ignite.table.mapper.Mapper;
import org.apache.ignite.table.partition.PartitionManager;
import org.apache.ignite.tx.Transaction;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
/**
* Client table API implementation.
*/
public class ClientTable implements Table {
private final int id;
// TODO: table name can change, this approach should probably be reworked, see https://issues.apache.org/jira/browse/IGNITE-21237.
private final QualifiedName name;
private final ReliableChannel ch;
private final MarshallersProvider marshallers;
private final ClientSql sql;
private final ConcurrentHashMap<Integer, CompletableFuture<ClientSchema>> schemas = new ConcurrentHashMap<>();
private final IgniteLogger log;
private static final int UNKNOWN_SCHEMA_VERSION = -1;
private volatile int latestSchemaVer = UNKNOWN_SCHEMA_VERSION;
private final Object latestSchemaLock = new Object();
private final Object partitionAssignmentLock = new Object();
private volatile PartitionAssignment partitionAssignment = null;
private volatile int partitionCount = -1;
private final ClientPartitionManager clientPartitionManager;
/**
* Constructor.
*
* @param ch Channel.
* @param marshallers Marshallers provider.
* @param id Table id.
* @param name Table name.
* @param sqlPartitionAwarenessMetadataCacheSize Size of the cache to store partition awareness metadata.
*/
public ClientTable(
ReliableChannel ch,
MarshallersProvider marshallers,
int id,
QualifiedName name,
int sqlPartitionAwarenessMetadataCacheSize
) {
assert ch != null;
assert marshallers != null;
assert name != null;
this.ch = ch;
this.marshallers = marshallers;
this.id = id;
this.name = name;
this.log = ClientUtils.logger(ch.configuration(), ClientTable.class);
this.sql = new ClientSql(ch, marshallers, sqlPartitionAwarenessMetadataCacheSize);
clientPartitionManager = new ClientPartitionManager(this);
}
/**
* Gets the table id.
*
* @return Table id.
*/
public int tableId() {
return id;
}
/**
* Gets the channel.
*
* @return Channel.
*/
ReliableChannel channel() {
return ch;
}
/** {@inheritDoc} */
@Override
public QualifiedName qualifiedName() {
return name;
}
@Override
public PartitionManager partitionManager() {
return clientPartitionManager;
}
/** {@inheritDoc} */
@Override
public <R> RecordView<R> recordView(Mapper<R> recMapper) {
Objects.requireNonNull(recMapper);
return new PublicApiClientRecordView<>(new ClientRecordView<>(this, sql, recMapper));
}
@Override
public RecordView<Tuple> recordView() {
return new PublicApiClientRecordView<>(new ClientRecordBinaryView(this, sql));
}
/** {@inheritDoc} */
@Override
public <K, V> KeyValueView<K, V> keyValueView(Mapper<K> keyMapper, Mapper<V> valMapper) {
Objects.requireNonNull(keyMapper);
Objects.requireNonNull(valMapper);
return new PublicApiClientKeyValueView<>(new ClientKeyValueView<>(this, sql, keyMapper, valMapper));
}
/** {@inheritDoc} */
@Override
public KeyValueView<Tuple, Tuple> keyValueView() {
return new PublicApiClientKeyValueView<>(new ClientKeyValueBinaryView(this, sql));
}
/**
* Returns latest known schema.
*
* <p>If latest schema is not known and/or not available locally, request the schema from server.
*
* @return A schema which is considered to be latest.
*/
public CompletableFuture<ClientSchema> getLatestSchema() {
// latestSchemaVer can be -1 (unknown) or a valid version.
// In case of unknown version, we request latest from the server and cache it with -1 key
// to avoid duplicate requests for latest schema.
return getSchema(latestSchemaVer);
}
@TestOnly
public CompletableFuture<ClientSchema> getSchemaByVersion(int schemaVersion) {
return getSchema(schemaVersion);
}
private CompletableFuture<ClientSchema> getSchema(int ver) {
CompletableFuture<ClientSchema> fut = schemas.computeIfAbsent(ver, this::loadSchema);
if (fut.isCompletedExceptionally()) {
// Do not return failed future. Remove it from the cache and try again.
schemas.remove(ver, fut);
fut = schemas.computeIfAbsent(ver, this::loadSchema);
}
return fut;
}
private CompletableFuture<ClientSchema> loadSchema(int ver) {
return ch.serviceAsync(ClientOp.SCHEMAS_GET, w -> {
w.out().packInt(id);
if (ver == UNKNOWN_SCHEMA_VERSION) {
w.out().packNil();
} else {
w.out().packInt(1);
w.out().packInt(ver);
}
}, r -> {
ClientMessageUnpacker clientMessageUnpacker = r.in();
int schemaCnt = clientMessageUnpacker.unpackInt();
if (schemaCnt == 0) {
log.warn("Schema not found [tableId=" + id + ", schemaVersion=" + ver + "]");
throw new IgniteException(INTERNAL_ERR, "Schema not found: " + ver);
}
ClientSchema last = null;
for (var i = 0; i < schemaCnt; i++) {
last = readSchema(r.in(), ver);
if (log.isDebugEnabled()) {
log.debug("Schema loaded [tableId=" + id + ", schemaVersion=" + last.version() + "]");
}
}
return last;
});
}
private ClientSchema readSchema(ClientMessageUnpacker in, int targetVer) {
var schemaVer = in.unpackInt();
var colCnt = in.unpackInt();
var columns = new ClientColumn[colCnt];
int valCnt = 0;
for (int i = 0; i < colCnt; i++) {
var propCnt = in.unpackInt();
assert propCnt >= 7;
var name = in.unpackString();
var type = ColumnTypeConverter.fromIdOrThrow(in.unpackInt());
var keyIndex = in.unpackInt();
var isNullable = in.unpackBoolean();
var colocationIndex = in.unpackInt();
var scale = in.unpackInt();
var precision = in.unpackInt();
var valIndex = keyIndex < 0 ? valCnt++ : -1;
// Skip unknown extra properties, if any.
in.skipValues(propCnt - 7);
var column = new ClientColumn(name, type, isNullable, keyIndex, valIndex, colocationIndex, i, scale, precision);
columns[i] = column;
}
var schema = new ClientSchema(schemaVer, columns, marshallers);
if (schemaVer != targetVer) {
schemas.put(schemaVer, completedFuture(schema));
}
synchronized (latestSchemaLock) {
if (schemaVer > latestSchemaVer) {
latestSchemaVer = schemaVer;
}
}
return schema;
}
/** {@inheritDoc} */
@Override
public String toString() {
return IgniteToStringBuilder.toString(ClientTable.class, this);
}
/**
* Performs a schema-based operation.
*
* @param opCode Op code.
* @param writer Writer.
* @param reader Reader.
* @param provider Partition awareness provider.
* @param tx Transaction.
* @param <T> Result type.
* @return Future representing pending completion of the operation.
*/
public <T> CompletableFuture<T> doSchemaOutOpAsync(
int opCode,
IgniteTriConsumer<ClientSchema, PayloadOutputChannel, WriteContext> writer,
Function<PayloadInputChannel, T> reader,
PartitionAwarenessProvider provider,
@Nullable Transaction tx) {
return doSchemaOutInOpAsync(
opCode,
writer,
(schema, unpacker) -> reader.apply(unpacker),
null,
false,
provider,
null,
null,
false,
tx);
}
/**
* Performs a schema-based operation.
*
* @param opCode Op code.
* @param writer Writer.
* @param reader Reader.
* @param provider Partition awareness provider.
* @param expectNotifications Whether to expect notifications as a result of the operation.
* @param tx Transaction.
* @param <T> Result type.
* @return Future representing pending completion of the operation.
*/
public <T> CompletableFuture<T> doSchemaOutOpAsync(
int opCode,
IgniteTriConsumer<ClientSchema, PayloadOutputChannel, WriteContext> writer,
Function<PayloadInputChannel, T> reader,
PartitionAwarenessProvider provider,
boolean expectNotifications,
@Nullable Transaction tx) {
return doSchemaOutInOpAsync(
opCode,
writer,
(schema, unpacker) -> reader.apply(unpacker),
null,
false,
provider,
null,
null,
expectNotifications,
tx);
}
/**
* Performs a schema-based operation.
*
* @param opCode Op code.
* @param writer Writer.
* @param reader Reader.
* @param provider Partition awareness provider.
* @param retryPolicyOverride Retry policy override.
* @param tx Transaction.
* @param <T> Result type.
* @return Future representing pending completion of the operation.
*/
<T> CompletableFuture<T> doSchemaOutOpAsync(
int opCode,
IgniteTriConsumer<ClientSchema, PayloadOutputChannel, WriteContext> writer,
Function<PayloadInputChannel, T> reader,
PartitionAwarenessProvider provider,
@Nullable RetryPolicy retryPolicyOverride,
@Nullable Transaction tx) {
return doSchemaOutInOpAsync(
opCode,
writer,
(schema, unpacker) -> reader.apply(unpacker),
null,
false,
provider,
retryPolicyOverride,
null,
false,
tx);
}
/**
* Performs a schema-based operation.
*
* @param opCode Op code.
* @param writer Writer.
* @param reader Reader.
* @param defaultValue Default value to use when server returns null.
* @param provider Partition awareness provider.
* @param tx Transaction.
* @param <T> Result type.
* @return Future representing pending completion of the operation.
*/
<T> CompletableFuture<T> doSchemaOutInOpAsync(
int opCode,
IgniteTriConsumer<ClientSchema, PayloadOutputChannel, WriteContext> writer,
BiFunction<ClientSchema, PayloadInputChannel, T> reader,
@Nullable T defaultValue,
PartitionAwarenessProvider provider,
@Nullable Transaction tx
) {
return doSchemaOutInOpAsync(opCode, writer, reader, defaultValue, true, provider, null, null, false, tx);
}
/**
* Performs a schema-based operation.
*
* @param opCode Op code.
* @param writer Writer.
* @param reader Reader.
* @param defaultValue Default value to use when server returns null.
* @param responseSchemaRequired Whether response schema is required to read the result.
* @param provider Partition awareness provider.
* @param retryPolicyOverride Retry policy override.
* @param schemaVersionOverride Schema version override.
* @param expectNotifications Whether to expect notifications as a result of the operation.
* @param tx Transaction.
* @param <T> Result type.
* @return Future representing pending completion of the operation.
*/
private <T> CompletableFuture<T> doSchemaOutInOpAsync(
int opCode,
IgniteTriConsumer<ClientSchema, PayloadOutputChannel, WriteContext> writer,
BiFunction<ClientSchema, PayloadInputChannel, T> reader,
@Nullable T defaultValue,
boolean responseSchemaRequired,
PartitionAwarenessProvider provider,
@Nullable RetryPolicy retryPolicyOverride,
@Nullable Integer schemaVersionOverride,
boolean expectNotifications,
@Nullable Transaction tx
) {
CompletableFuture<T> fut = new CompletableFuture<>();
CompletableFuture<ClientSchema> schemaFut = getSchema(schemaVersionOverride == null ? latestSchemaVer : schemaVersionOverride);
CompletableFuture<List<String>> partitionsFut = getPartitionAssignment();
// Wait for schema and partition assignment.
CompletableFuture.allOf(schemaFut, partitionsFut)
.thenCompose(v -> {
ClientSchema schema = schemaFut.getNow(null);
// If a partition mapping is known apriori, a request for explicit RW txn will be attempted in direct mode.
// Direct mode is only possible if:
// * a client's connection exists to a corresponding node.
// * a transaction has commit partition
@Nullable PartitionMapping pm = getPreferredNodeName(tableId(), provider, partitionsFut.getNow(null), schema);
// Write context carries request execution details over async chain.
WriteContext ctx = new WriteContext(ch.observableTimestamp());
CompletableFuture<@Nullable ClientTransaction> txStartFut = DirectTxUtils.ensureStarted(ch, tx, pm, ctx, ch -> {
// Enough to check only TX_PIGGYBACK flag - other tx flags are set if this flag is set.
boolean supports = ch.protocolContext().isFeatureSupported(TX_PIGGYBACK)
&& pm != null
&& ch.protocolContext().clusterNode().name().equals(pm.nodeConsistentId());
assert !supports || ch.protocolContext().allFeaturesSupported(TX_DIRECT_MAPPING, TX_DELAYED_ACKS);
return supports;
});
return txStartFut.thenCompose(tx0 -> {
return ch.serviceAsync(
opCode,
w -> writer.accept(schema, w, ctx),
r -> readSchemaAndReadData(schema, r, reader, defaultValue, responseSchemaRequired, ctx, tx0),
() -> DirectTxUtils.resolveChannel(ctx, ch, ClientOp.isWrite(opCode), tx0, pm),
retryPolicyOverride,
expectNotifications)
// Read resulting schema and the rest of the response.
.thenCompose(t -> loadSchemaAndReadData(t, reader))
.handle((ret, ex) -> {
if (ex != null) {
// Retry schema errors, if any.
Throwable cause = ex;
if (ctx.firstReqFut != null) {
// Create failed transaction.
ClientTransaction failed = new ClientTransaction(ctx.channel, id, ctx.readOnly, null, ctx.pm,
null, ch.observableTimestamp(), 0);
failed.fail();
ctx.firstReqFut.complete(failed);
fut.completeExceptionally(unwrapCause(ex));
return null;
}
// Don't attempt retrying in case of direct mapping. This may be improved in the future.
if (ctx.enlistmentToken == null) {
while (cause != null) {
if (cause instanceof ClientSchemaVersionMismatchException) {
// Retry with specific schema version.
int expectedVersion = ((ClientSchemaVersionMismatchException) cause).expectedVersion();
doSchemaOutInOpAsync(opCode, writer, reader, defaultValue, responseSchemaRequired,
provider,
retryPolicyOverride, expectedVersion, expectNotifications, tx)
.whenComplete((res0, err0) -> {
if (err0 != null) {
fut.completeExceptionally(err0);
} else {
fut.complete(res0);
}
});
return null;
} else if (schemaVersionOverride == null && cause instanceof UnmappedColumnsException) {
// Force load latest schema and revalidate user data against it.
// When schemaVersionOverride is not null, we already tried to load the schema.
schemas.remove(UNKNOWN_SCHEMA_VERSION);
doSchemaOutInOpAsync(opCode, writer, reader, defaultValue, responseSchemaRequired,
provider,
retryPolicyOverride, UNKNOWN_SCHEMA_VERSION, expectNotifications, tx)
.whenComplete((res0, err0) -> {
if (err0 != null) {
fut.completeExceptionally(err0);
} else {
fut.complete(res0);
}
});
return null;
}
cause = cause.getCause();
}
fut.completeExceptionally(ex);
} else {
// In case of direct mapping failure for any reason try to roll back the transaction.
tx0.rollbackAsync().handle((ignored, err0) -> {
if (err0 != null) {
ex.addSuppressed(err0);
}
fut.completeExceptionally(ex);
return (T) null;
});
}
} else {
fut.complete(ret);
}
return null;
});
});
}).exceptionally(ex -> {
fut.completeExceptionally(ex);
sneakyThrow(ex);
return null;
});
return fut;
}
private <T> @Nullable Object readSchemaAndReadData(
ClientSchema knownSchema,
PayloadInputChannel in,
BiFunction<ClientSchema, PayloadInputChannel, T> fn,
@Nullable T defaultValue,
boolean responseSchemaRequired,
WriteContext ctx,
@Nullable ClientTransaction tx0
) {
ClientMessageUnpacker in1 = in.in();
DirectTxUtils.readTx(in, ctx, tx0, ch.observableTimestamp());
int schemaVer = in1.unpackInt();
if (!responseSchemaRequired) {
ensureSchemaLoadedAsync(schemaVer);
return fn.apply(null, in);
}
if (in1.tryUnpackNil()) {
ensureSchemaLoadedAsync(schemaVer);
return defaultValue;
}
var resSchema = schemaVer == knownSchema.version() ? knownSchema : schemas.get(schemaVer);
if (resSchema != null) {
return fn.apply(knownSchema, in);
}
// Schema is not yet known - request.
// Retain unpacker - normally it is closed when this method exits.
in1.retain();
return new IgniteBiTuple<>(in, schemaVer);
}
private <T> CompletionStage<T> loadSchemaAndReadData(
Object data,
BiFunction<ClientSchema, PayloadInputChannel, T> fn
) {
if (!(data instanceof IgniteBiTuple)) {
return completedFuture((T) data);
}
var biTuple = (IgniteBiTuple<PayloadInputChannel, Integer>) data;
var in = biTuple.getKey();
var schemaId = biTuple.getValue();
assert in != null;
assert schemaId != null;
CompletableFuture<T> resFut = getSchema(schemaId).thenApply(schema -> fn.apply(schema, in));
// Close unpacker.
resFut.handle((tuple, err) -> {
in.close();
return null;
});
return resFut;
}
private void ensureSchemaLoadedAsync(int schemaVer) {
if (schemas.get(schemaVer) == null) {
// The schema is not needed for current response.
// Load it in the background to keep the client up to date with the latest version.
getSchema(schemaVer);
}
}
private static boolean isPartitionAssignmentValid(PartitionAssignment pa, long timestamp) {
return pa != null
&& pa.timestamp >= timestamp
&& !pa.partitionsFut.isCompletedExceptionally();
}
/**
* Gets partition assignment.
*
* @return The future.
*/
public synchronized CompletableFuture<List<String>> getPartitionAssignment() {
long timestamp = ch.partitionAssignmentTimestamp();
PartitionAssignment pa = partitionAssignment;
if (isPartitionAssignmentValid(pa, timestamp)) {
return pa.partitionsFut;
}
synchronized (partitionAssignmentLock) {
pa = partitionAssignment;
if (isPartitionAssignmentValid(pa, timestamp)) {
return pa.partitionsFut;
}
// Request assignment, save requested timestamp and future.
// This way multiple calls to getPartitionAssignment() will return the same future and won't send multiple requests.
PartitionAssignment newAssignment = new PartitionAssignment();
newAssignment.timestamp = timestamp;
newAssignment.partitionsFut = ch.serviceAsync(ClientOp.PARTITION_ASSIGNMENT_GET,
w -> {
w.out().packInt(id);
w.out().packLong(timestamp);
},
r -> {
int cnt = r.in().unpackInt();
if (cnt <= 0) {
throw new IgniteException(INTERNAL_ERR, "Invalid partition count returned by the server: " + cnt);
}
int oldPartitionCount = partitionCount;
if (oldPartitionCount < 0) {
partitionCount = cnt;
} else if (oldPartitionCount != cnt) {
String message = String.format("Partition count has changed for table '%s': %d -> %d",
name.toCanonicalForm(), oldPartitionCount, cnt);
throw new IgniteException(INTERNAL_ERR, message);
}
boolean assignmentAvailable = r.in().unpackBoolean();
if (!assignmentAvailable) {
// Invalidate current assignment so that we can retry on the next call.
newAssignment.timestamp = HybridTimestamp.NULL_HYBRID_TIMESTAMP;
// Return empty array so that per-partition batches can be initialized.
// We'll get the actual assignment on the next call.
return emptyAssignment(cnt);
}
// Returned timestamp can be newer than requested.
long ts = r.in().unpackLong();
assert ts >= timestamp : "Returned timestamp is older than requested: " + ts + " < " + timestamp;
newAssignment.timestamp = ts;
List<String> res = new ArrayList<>(cnt);
for (int i = 0; i < cnt; i++) {
res.add(r.in().tryUnpackNil() ? null : r.in().unpackString());
}
return res;
});
partitionAssignment = newAssignment;
return newAssignment.partitionsFut;
}
}
/**
* Gets partition count when available; otherwise, returns -1.
*
* @return Partition count, or -1 if not available.
*/
int tryGetPartitionCount() {
return partitionCount;
}
/**
* Batch with indexes.
*
* @param <E> Batch type element.
*/
static class Batch<E> {
List<E> batch = new ArrayList<>();
List<Integer> originalIndices = new ArrayList<>();
void add(E entry, int origIdx) {
batch.add(entry);
originalIndices.add(origIdx);
}
}
private static <E> void reduceWithKeepOrder(List<E> agg, List<E> cur, List<Integer> originalIndices) {
for (int i = 0; i < cur.size(); i++) {
E val = cur.get(i);
Integer orig = originalIndices.get(i);
agg.set(orig, val);
}
}
<R, E> CompletableFuture<R> split(
Transaction tx,
Collection<E> keys,
BiFunction<Collection<E>, PartitionAwarenessProvider, CompletableFuture<R>> fun,
@Nullable R initialValue,
Reducer<R> reducer,
BiFunction<ClientSchema, E, Integer> hashFunc
) {
assert tx != null;
CompletableFuture<ClientSchema> schemaFut = getSchema(latestSchemaVer);
CompletableFuture<List<String>> partitionsFut = getPartitionAssignment();
return CompletableFuture.allOf(schemaFut, partitionsFut)
.thenCompose(v -> {
ClientSchema schema = schemaFut.getNow(null);
@Nullable List<String> aff = partitionsFut.getNow(null);
if (aff == null) {
return fun.apply(keys, PartitionAwarenessProvider.NULL_PROVIDER);
}
Map<Integer, List<E>> mapped = IgniteUtils.newHashMap(aff.size());
List<CompletableFuture<R>> res = new ArrayList<>(aff.size());
for (E key : keys) {
int hash = hashFunc.apply(schema, key);
Integer part = Math.abs(hash % aff.size());
mapped.computeIfAbsent(part, k -> new ArrayList<>()).add(key);
}
for (Entry<Integer, List<E>> entry : mapped.entrySet()) {
res.add(fun.apply(entry.getValue(), PartitionAwarenessProvider.of(entry.getKey())));
}
return CompletableFuture.allOf(res.toArray(new CompletableFuture[0])).thenApply(ignored -> {
R in = initialValue;
for (CompletableFuture<R> val : res) {
in = reducer.reduce(in, val.getNow(null));
}
return in;
});
});
}
<E> CompletableFuture<List<E>> split(
Transaction tx,
Collection<E> keys,
BiFunction<Collection<E>, PartitionAwarenessProvider, CompletableFuture<List<E>>> fun,
BiFunction<ClientSchema, E, Integer> hashFunc
) {
assert tx != null;
CompletableFuture<ClientSchema> schemaFut = getSchema(latestSchemaVer);
CompletableFuture<List<String>> partitionsFut = getPartitionAssignment();
return CompletableFuture.allOf(schemaFut, partitionsFut)
.thenCompose(v -> {
ClientSchema schema = schemaFut.getNow(null);
@Nullable List<String> aff = partitionsFut.getNow(null);
if (aff == null) {
return fun.apply(keys, PartitionAwarenessProvider.NULL_PROVIDER);
}
Map<Integer, Batch<E>> mapped = IgniteUtils.newHashMap(aff.size());
int idx = 0;
for (E key : keys) {
int hash = hashFunc.apply(schema, key);
int part = Math.abs(hash % aff.size());
mapped.computeIfAbsent(part, k -> new Batch<>()).add(key, idx);
idx++;
}
List<CompletableFuture<List<E>>> res = new ArrayList<>(aff.size());
List<Batch<E>> batches = new ArrayList<>();
for (Entry<Integer, Batch<E>> entry : mapped.entrySet()) {
res.add(fun.apply(entry.getValue().batch, PartitionAwarenessProvider.of(entry.getKey())));
batches.add(entry.getValue());
}
return CompletableFuture.allOf(res.toArray(new CompletableFuture[0])).thenApply(ignored -> {
var in = new ArrayList<E>(Collections.nCopies(keys.size(), null));
for (int i = 0; i < res.size(); i++) {
CompletableFuture<List<E>> f = res.get(i);
reduceWithKeepOrder(in, f.getNow(null), batches.get(i).originalIndices);
}
return in;
});
});
}
@FunctionalInterface
interface Reducer<R> {
R reduce(@Nullable R agg, R cur);
}
private static @Nullable PartitionMapping getPreferredNodeName(
int tableId,
PartitionAwarenessProvider provider,
@Nullable List<String> partitions,
ClientSchema schema) {
assert provider != null;
if (partitions == null || partitions.isEmpty()) {
return null;
}
Integer partition = provider.partition();
if (partition != null) {
String node = partitions.get(partition);
if (node == null) {
return null; // Mapping is incomplete.
}
return new PartitionMapping(tableId, node, partition);
}
Integer hash = provider.getObjectHashCode(schema);
if (hash == null) {
return null;
}
int part = Math.abs(hash % partitions.size());
String node = partitions.get(part);
if (node == null) {
return null; // Mapping is incomplete.
}
return new PartitionMapping(tableId, node, part);
}
private static List<String> emptyAssignment(int size) {
List<String> emptyRes = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
emptyRes.add(null);
}
return emptyRes;
}
private static class PartitionAssignment {
volatile long timestamp = HybridTimestamp.NULL_HYBRID_TIMESTAMP;
CompletableFuture<List<String>> partitionsFut;
}
}
|
apache/lucene | 35,972 | lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene.sandbox.search;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.StoredFields;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreScorer;
import org.apache.lucene.search.ConstantScoreWeight;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.MultiPhraseQuery;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.ScorerSupplier;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.Weight;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.analysis.CannedTokenStream;
import org.apache.lucene.tests.analysis.MockTokenFilter;
import org.apache.lucene.tests.analysis.MockTokenizer;
import org.apache.lucene.tests.analysis.Token;
import org.apache.lucene.tests.index.RandomIndexWriter;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.BitSetIterator;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.automaton.Automata;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.Transition;
@LuceneTestCase.SuppressCodecs("SimpleText")
public class TestTermAutomatonQuery extends LuceneTestCase {
// "comes * sun"
public void testBasic1() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
// matches
doc.add(newTextField("field", "here comes the sun", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
// doesn't match
doc.add(newTextField("field", "here comes the other sun", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "comes");
int s2 = q.createState();
q.addAnyTransition(s1, s2);
int s3 = q.createState();
q.setAccept(s3, true);
q.addTransition(s2, s3, "sun");
q.finish();
assertEquals(1, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
// "comes * (sun|moon)"
public void testBasicSynonym() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes the sun", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "here comes the moon", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "comes");
int s2 = q.createState();
q.addAnyTransition(s1, s2);
int s3 = q.createState();
q.setAccept(s3, true);
q.addTransition(s2, s3, "sun");
q.addTransition(s2, s3, "moon");
q.finish();
assertEquals(2, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
// "comes sun" or "comes * sun"
public void testBasicSlop() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes the sun", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "here comes sun", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "here comes the other sun", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "comes");
int s2 = q.createState();
q.addAnyTransition(s1, s2);
int s3 = q.createState();
q.setAccept(s3, true);
q.addTransition(s1, s3, "sun");
q.addTransition(s2, s3, "sun");
q.finish();
assertEquals(2, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
// Verify posLength is "respected" at query time: index "speedy wifi
// network", search on "fast wi fi network" using (simulated!)
// query-time syn filter to add "wifi" over "wi fi" with posLength=2.
// To make this real we need a version of TS2A that operates on whole
// terms, not characters.
public void testPosLengthAtQueryTimeMock() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "speedy wifi network", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "speedy wi fi network", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "fast wifi network", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "fast wi fi network", Field.Store.NO));
w.addDocument(doc);
// doesn't match:
doc = new Document();
doc.add(newTextField("field", "slow wi fi network", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "fast");
q.addTransition(init, s1, "speedy");
int s2 = q.createState();
int s3 = q.createState();
q.addTransition(s1, s2, "wi");
q.addTransition(s1, s3, "wifi");
q.addTransition(s2, s3, "fi");
int s4 = q.createState();
q.addTransition(s3, s4, "network");
q.setAccept(s4, true);
q.finish();
// System.out.println("DOT:\n" + q.toDot());
assertEquals(4, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
public void testPosLengthAtQueryTimeTrueish() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "speedy wifi network", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "speedy wi fi network", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "fast wifi network", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "fast wi fi network", Field.Store.NO));
w.addDocument(doc);
// doesn't match:
doc = new Document();
doc.add(newTextField("field", "slow wi fi network", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TokenStream ts =
new CannedTokenStream(
token("fast", 1, 1),
token("speedy", 0, 1),
token("wi", 1, 1),
token("wifi", 0, 2),
token("fi", 1, 1),
token("network", 1, 1));
TermAutomatonQuery q = new TokenStreamToTermAutomatonQuery().toQuery("field", ts);
// System.out.println("DOT: " + q.toDot());
assertEquals(4, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
public void testSegsMissingTerms() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes the sun", Field.Store.NO));
w.addDocument(doc);
w.commit();
doc = new Document();
doc.add(newTextField("field", "here comes the moon", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "comes");
int s2 = q.createState();
q.addAnyTransition(s1, s2);
int s3 = q.createState();
q.setAccept(s3, true);
q.addTransition(s2, s3, "sun");
q.addTransition(s2, s3, "moon");
q.finish();
assertEquals(2, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
public void testInvalidLeadWithAny() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int s0 = q.createState();
int s1 = q.createState();
int s2 = q.createState();
q.setAccept(s2, true);
q.addAnyTransition(s0, s1);
q.addTransition(s1, s2, "b");
expectThrows(IllegalStateException.class, q::finish);
}
public void testInvalidTrailWithAny() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int s0 = q.createState();
int s1 = q.createState();
int s2 = q.createState();
q.setAccept(s2, true);
q.addTransition(s0, s1, "b");
q.addAnyTransition(s1, s2);
expectThrows(IllegalStateException.class, q::finish);
}
public void testAnyFromTokenStream() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes the sun", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "here comes the moon", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "here comes sun", Field.Store.NO));
w.addDocument(doc);
// Should not match:
doc = new Document();
doc.add(newTextField("field", "here comes the other sun", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TokenStream ts =
new CannedTokenStream(
token("comes", 1, 1),
token("comes", 0, 2),
token("*", 1, 1),
token("sun", 1, 1),
token("moon", 0, 1));
TermAutomatonQuery q = new TokenStreamToTermAutomatonQuery().toQuery("field", ts);
// System.out.println("DOT: " + q.toDot());
assertEquals(3, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
private static Token token(String term, int posInc, int posLength) {
final Token t = new Token(term, 0, term.length());
t.setPositionIncrement(posInc);
t.setPositionLength(posLength);
return t;
}
private static class RandomSynonymFilter extends TokenFilter {
private boolean synNext;
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private final PositionIncrementAttribute posIncAtt =
addAttribute(PositionIncrementAttribute.class);
public RandomSynonymFilter(TokenFilter in) {
super(in);
}
@Override
public boolean incrementToken() throws IOException {
if (synNext) {
AttributeSource.State state = captureState();
clearAttributes();
restoreState(state);
posIncAtt.setPositionIncrement(0);
termAtt.append("" + ((char) 97 + random().nextInt(3)));
synNext = false;
return true;
}
if (input.incrementToken()) {
if (random().nextInt(10) == 8) {
synNext = true;
}
return true;
} else {
return false;
}
}
@Override
public void reset() throws IOException {
super.reset();
synNext = false;
}
}
// TODO: incredibly slow
@Nightly
public void testRandom() throws Exception {
int numDocs = atLeast(50);
Directory dir = newDirectory();
// Adds occasional random synonyms:
Analyzer analyzer =
new Analyzer() {
@Override
public TokenStreamComponents createComponents(String fieldName) {
MockTokenizer tokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, true, 100);
tokenizer.setEnableChecks(true);
TokenFilter filter = new MockTokenFilter(tokenizer, MockTokenFilter.EMPTY_STOPSET);
filter = new RandomSynonymFilter(filter);
return new TokenStreamComponents(tokenizer, filter);
}
};
IndexWriterConfig iwc = newIndexWriterConfig(analyzer);
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
int numTokens = atLeast(10);
StringBuilder sb = new StringBuilder();
for (int j = 0; j < numTokens; j++) {
sb.append(' ');
sb.append((char) (97 + random().nextInt(3)));
}
String contents = sb.toString();
doc.add(newTextField("field", contents, Field.Store.NO));
doc.add(new StoredField("id", "" + i));
if (VERBOSE) {
System.out.println(" doc " + i + " -> " + contents);
}
w.addDocument(doc);
}
IndexReader r = w.getReader();
w.close();
IndexSearcher s = newSearcher(r);
// Used to match ANY using MultiPhraseQuery:
Term[] allTerms =
new Term[] {new Term("field", "a"), new Term("field", "b"), new Term("field", "c")};
int numIters = atLeast(1000);
for (int iter = 0; iter < numIters; iter++) {
// Build the (finite, no any transitions) TermAutomatonQuery and
// also the "equivalent" BooleanQuery and make sure they match the
// same docs:
BooleanQuery.Builder bq = new BooleanQuery.Builder();
int count = TestUtil.nextInt(random(), 1, 5);
Set<BytesRef> strings = new HashSet<>();
for (int i = 0; i < count; i++) {
StringBuilder sb = new StringBuilder();
int numTokens = TestUtil.nextInt(random(), 1, 5);
for (int j = 0; j < numTokens; j++) {
if (j > 0 && j < numTokens - 1 && random().nextInt(5) == 3) {
sb.append('*');
} else {
sb.append((char) (97 + random().nextInt(3)));
}
}
String string = sb.toString();
MultiPhraseQuery.Builder mpqb = new MultiPhraseQuery.Builder();
for (int j = 0; j < string.length(); j++) {
if (string.charAt(j) == '*') {
mpqb.add(allTerms);
} else {
mpqb.add(new Term("field", "" + string.charAt(j)));
}
}
bq.add(mpqb.build(), BooleanClause.Occur.SHOULD);
strings.add(new BytesRef(string));
}
List<BytesRef> stringsList = new ArrayList<>(strings);
Collections.sort(stringsList);
Automaton a = Automata.makeStringUnion(stringsList);
// Translate automaton to query:
TermAutomatonQuery q = new TermAutomatonQuery("field");
int numStates = a.getNumStates();
for (int i = 0; i < numStates; i++) {
q.createState();
q.setAccept(i, a.isAccept(i));
}
Transition t = new Transition();
for (int i = 0; i < numStates; i++) {
int transCount = a.initTransition(i, t);
for (int j = 0; j < transCount; j++) {
a.getNextTransition(t);
for (int label = t.min; label <= t.max; label++) {
if ((char) label == '*') {
q.addAnyTransition(t.source, t.dest);
} else {
q.addTransition(t.source, t.dest, "" + (char) label);
}
}
}
}
q.finish();
if (VERBOSE) {
System.out.println("TEST: iter=" + iter);
for (BytesRef string : stringsList) {
System.out.println(" string: " + string.utf8ToString());
}
System.out.println(q.toDot());
}
Query q1 = q;
Query q2 = bq.build();
if (random().nextInt(5) == 1) {
if (VERBOSE) {
System.out.println(" use random filter");
}
RandomQuery filter = new RandomQuery(random().nextLong(), random().nextFloat());
q1 = new BooleanQuery.Builder().add(q1, Occur.MUST).add(filter, Occur.FILTER).build();
q2 = new BooleanQuery.Builder().add(q2, Occur.MUST).add(filter, Occur.FILTER).build();
}
TopDocs hits1 = s.search(q1, numDocs);
TopDocs hits2 = s.search(q2, numDocs);
Set<String> hits1Docs = toDocIDs(s, hits1);
Set<String> hits2Docs = toDocIDs(s, hits2);
try {
assertEquals(hits2.totalHits.value(), hits1.totalHits.value());
assertEquals(hits2Docs, hits1Docs);
} catch (AssertionError ae) {
System.out.println("FAILED:");
for (String id : hits1Docs) {
if (hits2Docs.contains(id) == false) {
System.out.printf(Locale.ROOT, " id=%3s matched but should not have%n", id);
}
}
for (String id : hits2Docs) {
if (hits1Docs.contains(id) == false) {
System.out.printf(Locale.ROOT, " id=%3s did not match but should have%n", id);
}
}
throw ae;
}
}
IOUtils.close(r, dir, analyzer);
}
private Set<String> toDocIDs(IndexSearcher s, TopDocs hits) throws IOException {
Set<String> result = new HashSet<>();
StoredFields storedFields = s.storedFields();
for (ScoreDoc hit : hits.scoreDocs) {
result.add(storedFields.document(hit.doc).get("id"));
}
return result;
}
private static class RandomQuery extends Query {
private final long seed;
private final float density;
// density should be 0.0 ... 1.0
public RandomQuery(long seed, float density) {
this.seed = seed;
this.density = density;
}
@Override
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)
throws IOException {
return new ConstantScoreWeight(this, boost) {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
int maxDoc = context.reader().maxDoc();
FixedBitSet bits = new FixedBitSet(maxDoc);
Random random = new Random(seed ^ context.docBase);
for (int docID = 0; docID < maxDoc; docID++) {
if (random.nextFloat() <= density) {
bits.set(docID);
// System.out.println(" acc id=" + idSource.getInt(docID) + " docID=" + docID);
}
}
final var scorer =
new ConstantScoreScorer(
score(), scoreMode, new BitSetIterator(bits, bits.approximateCardinality()));
return new DefaultScorerSupplier(scorer);
}
@Override
public boolean isCacheable(LeafReaderContext ctx) {
return false;
}
};
}
@Override
public void visit(QueryVisitor visitor) {}
@Override
public String toString(String field) {
return "RandomFilter(seed=" + seed + ",density=" + density + ")";
}
@Override
public boolean equals(Object other) {
return sameClassAs(other) && equalsTo(getClass().cast(other));
}
private boolean equalsTo(RandomQuery other) {
return seed == other.seed && density == other.density;
}
@Override
public int hashCode() {
return classHash() ^ Objects.hash(seed, density);
}
}
/** See if we can create a TAQ with cycles */
public void testWithCycles1() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes here comes", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "comes foo", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
int s2 = q.createState();
q.addTransition(init, s1, "here");
q.addTransition(s1, s2, "comes");
q.addTransition(s2, s1, "here");
q.setAccept(s1, true);
q.finish();
assertEquals(1, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
/** See if we can create a TAQ with cycles */
public void testWithCycles2() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes kaoma", Field.Store.NO));
w.addDocument(doc);
doc = new Document();
doc.add(newTextField("field", "here comes sun sun sun sun kaoma", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "here");
int s2 = q.createState();
q.addTransition(s1, s2, "comes");
int s3 = q.createState();
q.addTransition(s2, s3, "sun");
q.addTransition(s3, s3, "sun");
int s4 = q.createState();
q.addTransition(s3, s4, "kaoma");
q.setAccept(s4, true);
q.finish();
assertEquals(1, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
public void testTermDoesNotExist() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TokenStream ts = new CannedTokenStream(token("a", 1, 1));
TermAutomatonQuery q = new TokenStreamToTermAutomatonQuery().toQuery("field", ts);
// System.out.println("DOT: " + q.toDot());
assertEquals(0, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
public void testOneTermDoesNotExist() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TokenStream ts = new CannedTokenStream(token("a", 1, 1), token("x", 1, 1));
TermAutomatonQuery q = new TokenStreamToTermAutomatonQuery().toQuery("field", ts);
// System.out.println("DOT: " + q.toDot());
assertEquals(0, s.search(q, 1).totalHits.value());
IOUtils.close(w, r, dir);
}
public void testEmptyString() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int initState = q.createState();
q.setAccept(initState, true);
expectThrows(IllegalStateException.class, q::finish);
}
public void testRewriteNoMatch() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
q.createState(); // initState
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
assertTrue(q.rewrite(newSearcher(r)) instanceof MatchNoDocsQuery);
IOUtils.close(w, r, dir);
}
public void testRewriteTerm() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int initState = q.createState();
int s1 = q.createState();
q.addTransition(initState, s1, "foo");
q.setAccept(s1, true);
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
Query rewrite = q.rewrite(newSearcher(r));
assertTrue(rewrite instanceof TermQuery);
assertEquals(new Term("field", "foo"), ((TermQuery) rewrite).getTerm());
IOUtils.close(w, r, dir);
}
public void testRewriteSimplePhrase() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int initState = q.createState();
int s1 = q.createState();
int s2 = q.createState();
q.addTransition(initState, s1, "foo");
q.addTransition(s1, s2, "bar");
q.setAccept(s2, true);
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
Query rewrite = q.rewrite(newSearcher(r));
assertTrue(rewrite instanceof PhraseQuery);
Term[] terms = ((PhraseQuery) rewrite).getTerms();
assertEquals(new Term("field", "foo"), terms[0]);
assertEquals(new Term("field", "bar"), terms[1]);
int[] positions = ((PhraseQuery) rewrite).getPositions();
assertEquals(0, positions[0]);
assertEquals(1, positions[1]);
IOUtils.close(w, r, dir);
}
/* Implement a custom term automaton query to ensure that rewritten queries
* do not get rewritten to primitive queries. The custom extension will allow
* the following explain tests to evaluate Explain for the query we intend to
* test, TermAutomatonQuery.
* */
private static class CustomTermAutomatonQuery extends TermAutomatonQuery {
public CustomTermAutomatonQuery(String field) {
super(field);
}
@Override
public Query rewrite(IndexSearcher searcher) throws IOException {
return this;
}
}
public void testExplainNoMatchingDocument() throws Exception {
CustomTermAutomatonQuery q = new CustomTermAutomatonQuery("field");
int initState = q.createState();
int s1 = q.createState();
q.addTransition(initState, s1, "xml");
q.setAccept(s1, true);
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "protobuf", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher searcher = newSearcher(r);
Query rewrittenQuery = q.rewrite(searcher);
assertTrue(rewrittenQuery instanceof TermAutomatonQuery);
TopDocs topDocs = searcher.search(rewrittenQuery, 10);
assertEquals(0, topDocs.totalHits.value());
Explanation explanation = searcher.explain(rewrittenQuery, 0);
assertFalse("Explanation should indicate no match", explanation.isMatch());
IOUtils.close(w, r, dir);
}
// TODO: improve experience of working with explain
public void testExplainMatchingDocuments() throws Exception {
CustomTermAutomatonQuery q = new CustomTermAutomatonQuery("field");
int initState = q.createState();
int s1 = q.createState();
int s2 = q.createState();
q.addTransition(initState, s1, "xml");
q.addTransition(s1, s2, "json");
q.addTransition(s1, s2, "protobuf");
q.setAccept(s2, true);
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc1 = new Document();
doc1.add(newTextField("field", "xml json", Field.Store.NO));
w.addDocument(doc1);
Document doc2 = new Document();
doc2.add(newTextField("field", "xml protobuf", Field.Store.NO));
w.addDocument(doc2);
Document doc3 = new Document();
doc3.add(newTextField("field", "xml qux", Field.Store.NO));
w.addDocument(doc3);
IndexReader r = w.getReader();
IndexSearcher searcher = newSearcher(r);
Query rewrittenQuery = q.rewrite(searcher);
assertTrue(
"Rewritten query should be an instance of TermAutomatonQuery",
rewrittenQuery instanceof TermAutomatonQuery);
TopDocs topDocs = searcher.search(q, 10);
assertEquals(2, topDocs.totalHits.value());
for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
Explanation explanation = searcher.explain(q, scoreDoc.doc);
assertNotNull("Explanation should not be null", explanation);
assertTrue("Explanation should indicate a match", explanation.isMatch());
}
IOUtils.close(w, r, dir);
}
public void testRewritePhraseWithAny() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int initState = q.createState();
int s1 = q.createState();
int s2 = q.createState();
int s3 = q.createState();
q.addTransition(initState, s1, "foo");
q.addAnyTransition(s1, s2);
q.addTransition(s2, s3, "bar");
q.setAccept(s3, true);
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
Query rewrite = q.rewrite(newSearcher(r));
assertTrue(rewrite instanceof PhraseQuery);
Term[] terms = ((PhraseQuery) rewrite).getTerms();
assertEquals(new Term("field", "foo"), terms[0]);
assertEquals(new Term("field", "bar"), terms[1]);
int[] positions = ((PhraseQuery) rewrite).getPositions();
assertEquals(0, positions[0]);
assertEquals(2, positions[1]);
IOUtils.close(w, r, dir);
}
public void testRewriteSimpleMultiPhrase() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int initState = q.createState();
int s1 = q.createState();
q.addTransition(initState, s1, "foo");
q.addTransition(initState, s1, "bar");
q.setAccept(s1, true);
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
Query rewrite = q.rewrite(newSearcher(r));
assertTrue(rewrite instanceof MultiPhraseQuery);
Term[][] terms = ((MultiPhraseQuery) rewrite).getTermArrays();
assertEquals(1, terms.length);
assertEquals(2, terms[0].length);
assertEquals(new Term("field", "foo"), terms[0][0]);
assertEquals(new Term("field", "bar"), terms[0][1]);
int[] positions = ((MultiPhraseQuery) rewrite).getPositions();
assertEquals(1, positions.length);
assertEquals(0, positions[0]);
IOUtils.close(w, r, dir);
}
public void testRewriteMultiPhraseWithAny() throws Exception {
TermAutomatonQuery q = new TermAutomatonQuery("field");
int initState = q.createState();
int s1 = q.createState();
int s2 = q.createState();
int s3 = q.createState();
q.addTransition(initState, s1, "foo");
q.addTransition(initState, s1, "bar");
q.addAnyTransition(s1, s2);
q.addTransition(s2, s3, "baz");
q.setAccept(s3, true);
q.finish();
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "x y z", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
Query rewrite = q.rewrite(newSearcher(r));
assertTrue(rewrite instanceof MultiPhraseQuery);
Term[][] terms = ((MultiPhraseQuery) rewrite).getTermArrays();
assertEquals(2, terms.length);
assertEquals(2, terms[0].length);
assertEquals(new Term("field", "foo"), terms[0][0]);
assertEquals(new Term("field", "bar"), terms[0][1]);
assertEquals(1, terms[1].length);
assertEquals(new Term("field", "baz"), terms[1][0]);
int[] positions = ((MultiPhraseQuery) rewrite).getPositions();
assertEquals(2, positions.length);
assertEquals(0, positions[0]);
assertEquals(2, positions[1]);
IOUtils.close(w, r, dir);
}
// we query with sun|moon but moon doesn't exist
public void testOneTermMissing() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes the sun", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("field");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "comes");
int s2 = q.createState();
q.addAnyTransition(s1, s2);
int s3 = q.createState();
q.setAccept(s3, true);
q.addTransition(s2, s3, "sun");
q.addTransition(s2, s3, "moon");
q.finish();
assertEquals(1, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
// we query with sun|moon but no terms exist for the field
public void testFieldMissing() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(newTextField("field", "here comes the sun", Field.Store.NO));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
TermAutomatonQuery q = new TermAutomatonQuery("bogusfield");
int init = q.createState();
int s1 = q.createState();
q.addTransition(init, s1, "comes");
int s2 = q.createState();
q.addAnyTransition(s1, s2);
int s3 = q.createState();
q.setAccept(s3, true);
q.addTransition(s2, s3, "sun");
q.addTransition(s2, s3, "moon");
q.finish();
assertEquals(0, s.search(q, 1).totalHits.value());
w.close();
r.close();
dir.close();
}
}
|
apache/metamodel | 36,083 | jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcTestTemplates.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.metamodel.jdbc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.StringReader;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.metamodel.BatchUpdateScript;
import org.apache.metamodel.UpdateCallback;
import org.apache.metamodel.UpdateScript;
import org.apache.metamodel.UpdateSummary;
import org.apache.metamodel.create.ColumnCreationBuilder;
import org.apache.metamodel.create.CreateTable;
import org.apache.metamodel.create.TableCreationBuilder;
import org.apache.metamodel.data.DataSet;
import org.apache.metamodel.data.Row;
import org.apache.metamodel.drop.DropTable;
import org.apache.metamodel.query.Query;
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.ColumnType;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
import org.apache.metamodel.update.Update;
import org.apache.metamodel.util.DateUtils;
import org.apache.metamodel.util.FileHelper;
import org.apache.metamodel.util.Month;
import org.junit.Ignore;
/**
* Some reusable test methods
*/
@Ignore
public class JdbcTestTemplates {
public static void interpretationOfNulls(Connection conn) throws Exception {
final JdbcDataContext dc = new JdbcDataContext(conn);
final Schema schema = dc.getDefaultSchema();
if (dc.getTableByQualifiedLabel("test_table") != null) {
dc.executeUpdate(new DropTable(schema, "test_table"));
}
final Map<Object, Object> map = new HashMap<Object, Object>();
try {
final UpdateSummary summary = dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
ColumnCreationBuilder createTableBuilder = cb.createTable(schema, "test_table").withColumn("id")
.ofType(ColumnType.FLOAT).withColumn("code").ofType(ColumnType.VARCHAR).ofSize(10);
Table table = createTableBuilder.execute();
cb.insertInto(table).value("id", 1.0).value("code", "C01").execute();
cb.insertInto(table).value("id", 2.0).value("code", "C02").execute();
cb.insertInto(table).value("id", 3.0).value("code", null).execute();
cb.insertInto(table).value("id", 4.0).value("code", "C02").execute();
}
});
assertEquals(4, summary.getInsertedRows().get().intValue());
assertEquals(1, getCount(dc.query().from("test_table").selectCount().where("code").isNull().execute()));
assertEquals(3, getCount(dc.query().from("test_table").selectCount().where("code").isNotNull().execute()));
assertEquals(2, getCount(dc.query().from("test_table").selectCount().where("code").ne("C02").execute()));
// we put the results into a map, because databases are not in
// agreement
// wrt. if NULL is greater than or less than other values, so
// ordering
// does not help
DataSet ds = dc.query().from("test_table").select("code").selectCount().groupBy("code").execute();
assertTrue(ds.next());
map.put(ds.getRow().getValue(0), ds.getRow().getValue(1));
assertTrue(ds.next());
map.put(ds.getRow().getValue(0), ds.getRow().getValue(1));
assertTrue(ds.next());
map.put(ds.getRow().getValue(0), ds.getRow().getValue(1));
assertFalse(ds.next());
ds.close();
} finally {
dc.executeUpdate(new DropTable(schema, "test_table"));
}
assertEquals(1, ((Number) map.get(null)).intValue());
assertEquals(1, ((Number) map.get("C01")).intValue());
assertEquals(2, ((Number) map.get("C02")).intValue());
assertEquals(3, map.size());
}
private static int getCount(DataSet ds) {
assertTrue(ds.next());
Row row = ds.getRow();
assertFalse(ds.next());
ds.close();
Number count = (Number) row.getValue(0);
return count.intValue();
}
public static void differentOperatorsTest(Connection conn) throws Exception {
assertNotNull(conn);
assertFalse(conn.isReadOnly());
final JdbcDataContext dc = new JdbcDataContext(conn);
final Schema schema = dc.getDefaultSchema();
if (dc.getTableByQualifiedLabel("test_table") != null) {
dc.executeUpdate(new DropTable("test_table"));
}
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
ColumnCreationBuilder createTableBuilder = cb.createTable(schema, "test_table").withColumn("id")
.ofType(ColumnType.FLOAT).withColumn("code").ofType(ColumnType.VARCHAR).ofSize(10);
Table table = createTableBuilder.execute();
cb.insertInto(table).value("id", 1.0).value("code", "C01").execute();
cb.insertInto(table).value("id", 2.0).value("code", "C02").execute();
cb.insertInto(table).value("id", 3.0).value("code", null).execute();
cb.insertInto(table).value("id", 4.0).value("code", "C04").execute();
}
});
DataSet ds;
// regular EQUALS
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").eq("C02").execute();
assertTrue(ds.next());
assertEquals("1", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// regular NOT EQUALS
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").ne("C02").execute();
assertTrue(ds.next());
assertEquals("3", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// regular GREATER THAN
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("id").gt(2).execute();
assertTrue(ds.next());
assertEquals("2", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// regular LESS THAN
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("id").lt(2).execute();
assertTrue(ds.next());
assertEquals("1", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// IS NULL
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").isNull().execute();
assertTrue(ds.next());
assertEquals("1", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// IS NOT NULL
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").isNotNull().execute();
assertTrue(ds.next());
assertEquals("3", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// LIKE
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").like("C%").execute();
assertTrue(ds.next());
assertEquals("3", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// NOT LIKE
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").notLike("%1").execute();
assertTrue(ds.next());
assertEquals("2", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// regular IN (with string)
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").in("C01", "C02")
.execute();
assertTrue(ds.next());
assertEquals("2", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// regular IN (with decimals)
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("id").in(1.0, 2.0, 4.0).execute();
assertTrue(ds.next());
assertEquals("3", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// regular NOT IN (with string)
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code").notIn("C01", "C02")
.execute();
assertTrue(ds.next());
assertEquals("1", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// regular NOT IN (with decimals)
ds = dc.query().from(schema.getTableByName("test_table")).selectCount().where("id").notIn(1.0, 2.0, 4.0).execute();
assertTrue(ds.next());
assertEquals("1", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
// irregular IN (with null value) - (currently uses SQL's standard way
// of understanding NULL - see ticket #1058)
Query query = dc.query().from(schema.getTableByName("test_table")).selectCount().where("code")
.in("foobar", null, "baz").toQuery();
String sql = dc.getQueryRewriter().rewriteQuery(query);
assertTrue(sql, sql.endsWith(" IN ('foobar' , 'baz')"));
ds = dc.executeQuery(query);
assertTrue(ds.next());
assertEquals("0", ds.getRow().getValue(0).toString());
assertFalse(ds.next());
ds.close();
}
public static void meaningOfOneSizeChar(Connection conn) throws Exception {
assertNotNull(conn);
assertFalse(conn.isReadOnly());
final JdbcDataContext dc = new JdbcDataContext(conn);
final Schema schema = dc.getDefaultSchema();
if (dc.getTableByQualifiedLabel("test_table") != null) {
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
cb.dropTable("test_table").execute();
}
});
}
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
ColumnCreationBuilder createTableBuilder = cb.createTable(schema, "test_table").withColumn("id")
.ofType(ColumnType.INTEGER).withColumn("code").ofType(ColumnType.CHAR).ofSize(1);
String sql = createTableBuilder.toSql();
assertTrue(sql, sql.indexOf("test_table (id INTEGER,code CHAR(1))") != -1);
Table table = createTableBuilder.execute();
cb.insertInto(table).value("id", 1).value("code", 'P').execute();
cb.insertInto(table).value("id", 2).value("code", 'O').execute();
cb.insertInto(table).value("id", 3).value("code", null).execute();
}
});
DataSet ds = dc.query().from(schema.getTableByName("test_table")).select("code").orderBy("id").execute();
assertTrue(ds.next());
assertTrue(ds.getRow().getValue(0) instanceof String);
assertTrue(ds.next());
assertTrue(ds.getRow().getValue(0) instanceof String);
assertTrue(ds.next());
assertNull(ds.getRow().getValue(0));
assertFalse(ds.next());
ds.close();
}
public static void automaticConversionWhenInsertingString(Connection conn) throws Exception {
assertNotNull(conn);
try {
// clean up, if necessary
conn.createStatement().execute("DROP TABLE test_table");
} catch (SQLException e) {
// do nothing
}
assertFalse(conn.isReadOnly());
JdbcDataContext dc = new JdbcDataContext(conn);
final Schema schema = dc.getDefaultSchema();
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
Table table = cb.createTable(schema, "test_table").withColumn("id").ofType(ColumnType.INTEGER)
.withColumn("birthdate1").ofType(ColumnType.DATE).withColumn("birthdate2")
.ofType(ColumnType.TIMESTAMP).execute();
cb.insertInto(table).value("id", "1").value("birthdate1", null).execute();
cb.insertInto(table).value("id", 2).value("birthdate1", "2011-12-21")
.value("birthdate2", "2011-12-21 14:00:00").execute();
}
});
DataSet ds = dc.query().from("test_table").select("id").and("birthdate1").execute();
assertTrue(ds.next());
assertEquals("Row[values=[1, null]]", ds.getRow().toString());
assertEquals("java.lang.Integer", ds.getRow().getValue(0).getClass().getName());
assertTrue(ds.next());
assertEquals("Row[values=[2, 2011-12-21]]", ds.getRow().toString());
assertEquals("java.sql.Date", ds.getRow().getValue(1).getClass().getName());
assertFalse(ds.next());
ds.close();
Query query = dc.query().from("test_table").select("id").where("birthdate2")
.lessThan(DateUtils.get(2011, Month.DECEMBER, 20)).toQuery();
try {
ds = dc.executeQuery(query);
} catch (Exception e) {
System.out.println("Failing query was: " + dc.getQueryRewriter().rewriteQuery(query));
throw e;
}
assertFalse(ds.next());
ds.close();
ds = dc.query().from("test_table").select("id").where("birthdate2")
.greaterThan(DateUtils.get(2011, Month.DECEMBER, 20)).execute();
assertTrue(ds.next());
assertEquals("Row[values=[2]]", ds.getRow().toString());
assertFalse(ds.next());
ds.close();
final UpdateSummary updateSummary = dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.deleteFrom("test_table").where("id").in(Arrays.<String> asList("1", "2")).execute();
}
});
assertEquals(2, updateSummary.getDeletedRows().get().intValue());
assertEquals(0, updateSummary.getUpdatedRows().get().intValue());
assertEquals(0, updateSummary.getInsertedRows().get().intValue());
ds = dc.query().from("test_table").selectCount().where("id").eq(2).or("id").eq(1).execute();
assertTrue(ds.next());
assertEquals(0, ((Number) ds.getRow().getValue(0)).intValue());
assertFalse(ds.next());
ds.close();
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.dropTable("test_table").execute();
}
});
}
public static void createInsertAndUpdateDateTypes(final JdbcDataContext dc, final Schema schema,
final String tableName) throws Exception {
if (schema.getTableByName(tableName) != null) {
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.dropTable(schema.getTableByName(tableName)).execute();
}
});
}
dc.executeUpdate(new BatchUpdateScript() {
@Override
public void run(UpdateCallback cb) {
Table table = cb.createTable(schema, tableName).withColumn("id").asPrimaryKey()
.ofType(ColumnType.INTEGER).withColumn("birthdate").ofType(ColumnType.DATE)
.withColumn("wakemeup").ofType(ColumnType.TIME).execute();
// insert record 1
{
// create a 7:55 time.
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
cal.set(Calendar.HOUR_OF_DAY, 7);
cal.set(Calendar.MINUTE, 55);
Date wakeUpTime = cal.getTime();
cb.insertInto(table).value("id", 1).value("birthdate", DateUtils.get(1982, Month.APRIL, 20))
.value("wakemeup", wakeUpTime).execute();
}
// insert record 2
{
// create a 18:35 time.
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
cal.set(Calendar.HOUR_OF_DAY, 18);
cal.set(Calendar.MINUTE, 35);
Date wakeUpTime = cal.getTime();
cb.insertInto(table).value("id", 2).value("birthdate", DateUtils.get(1982, Month.APRIL, 21))
.value("wakemeup", wakeUpTime).execute();
}
}
});
try {
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
cb.insertInto(schema.getTableByName(tableName)).value("id", 3).value("birthdate", "2011-12-21")
.value("wakemeup", "12:00").execute();
}
});
DataSet ds = dc.query().from(schema.getTableByName(tableName)).select("id", "birthdate", "wakemeup")
.orderBy("id").execute();
assertTrue(ds.next());
assertEquals("1", ds.getRow().getValue(0).toString());
assertEquals("1982-04-20", ds.getRow().getValue(1).toString());
assertTrue("Actual value was: " + ds.getRow().getValue(2),
ds.getRow().getValue(2).toString().startsWith("07:55:00"));
assertTrue(ds.next());
assertEquals("2", ds.getRow().getValue(0).toString());
assertEquals("1982-04-21", ds.getRow().getValue(1).toString());
assertTrue("Actual value was: " + ds.getRow().getValue(2),
ds.getRow().getValue(2).toString().startsWith("18:35:00"));
assertTrue(ds.next());
assertEquals("3", ds.getRow().getValue(0).toString());
assertEquals("2011-12-21", ds.getRow().getValue(1).toString());
assertTrue("Actual value was: " + ds.getRow().getValue(2),
ds.getRow().getValue(2).toString().startsWith("12:00"));
assertFalse(ds.next());
ds.close();
final UpdateSummary updateSummary = dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
// update record 1
// create a 08:00 time.
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
cal.set(Calendar.HOUR_OF_DAY, 8);
cal.set(Calendar.MINUTE, 00);
Date wakeUpTime = cal.getTime();
callback.update(schema.getTableByName(tableName))
.value("birthdate", DateUtils.get(1982, Month.APRIL, 21)).value("wakemeup", wakeUpTime)
.where("birthdate").isEquals(DateUtils.get(1982, Month.APRIL, 20)).execute();
}
});
assertEquals(0, updateSummary.getInsertedRows().get().intValue());
assertEquals(0, updateSummary.getDeletedRows().get().intValue());
assertEquals(1, updateSummary.getUpdatedRows().get().intValue());
ds = dc.query().from(schema.getTableByName(tableName)).select("id", "birthdate", "wakemeup").orderBy("id")
.execute();
assertTrue(ds.next());
assertEquals("1", ds.getRow().getValue(0).toString());
assertEquals("1982-04-21", ds.getRow().getValue(1).toString());
assertTrue("Actual value was: " + ds.getRow().getValue(2),
ds.getRow().getValue(2).toString().startsWith("08:00:00"));
assertTrue(ds.next());
assertEquals("2", ds.getRow().getValue(0).toString());
assertEquals("1982-04-21", ds.getRow().getValue(1).toString());
assertTrue("Actual value was: " + ds.getRow().getValue(2),
ds.getRow().getValue(2).toString().startsWith("18:35:00"));
assertTrue(ds.next());
assertEquals("3", ds.getRow().getValue(0).toString());
assertEquals("2011-12-21", ds.getRow().getValue(1).toString());
assertTrue("Actual value was: " + ds.getRow().getValue(2),
ds.getRow().getValue(2).toString().startsWith("12:00"));
assertFalse(ds.next());
ds.close();
} finally {
if (schema.getTableByName(tableName) != null) {
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.dropTable(schema.getTableByName(tableName)).execute();
}
});
}
}
}
public static void convertClobToString(JdbcDataContext dc) {
System.setProperty(JdbcDataContext.SYSTEM_PROPERTY_CONVERT_LOBS, "true");
final Schema schema = dc.getDefaultSchema();
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
Table table = callback.createTable(schema, "clob_test_table").withColumn("id")
.ofType(ColumnType.INTEGER).asPrimaryKey().withColumn("foo").ofType(ColumnType.CLOB).execute();
callback.insertInto(table).value("id", 1).value("foo", "baaaaz").execute();
StringReader sr = new StringReader("foooooooabavlsdk\nflskmflsdk");
callback.insertInto(table).value("id", 2).value("foo", sr).execute();
}
});
DataSet ds;
ds = dc.query().from(schema, "clob_test_table").selectCount().execute();
assertTrue(ds.next());
assertEquals("Row[values=[2]]", ds.getRow().toString());
ds.close();
ds = dc.query().from(schema, "clob_test_table").select("id", "foo").orderBy("id").execute();
assertTrue(ds.next());
assertEquals(1, ds.getRow().getValue(0));
final Object clobValue1 = ds.getRow().getValue(1);
assertTrue(clobValue1 instanceof Clob || clobValue1 instanceof String);
assertTrue(ds.next());
assertEquals(2, ds.getRow().getValue(0));
final Object clobValue2 = ds.getRow().getValue(1);
assertTrue(clobValue2 instanceof Clob || clobValue2 instanceof String);
assertFalse(ds.next());
ds.close();
ds = dc.query().from(schema, "clob_test_table").select("id", "foo").orderBy("id").execute();
assertTrue(ds.next());
assertEquals("Row[values=[1, baaaaz]]", ds.getRow().toString());
assertTrue(ds.next());
assertEquals("Row[values=[2, foooooooabavlsdk\nflskmflsdk]]", ds.getRow().toString());
assertFalse(ds.next());
ds.close();
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.dropTable(schema, "clob_test_table").execute();
}
});
System.setProperty(JdbcDataContext.SYSTEM_PROPERTY_CONVERT_LOBS, "");
}
public static void simpleCreateInsertUpdateAndDrop(final JdbcDataContext dataContext, final String testTableName) {
final Schema defaultSchema = dataContext.getDefaultSchema();
if (defaultSchema.getTableByName(testTableName) != null) {
// clean up before
dataContext.executeUpdate(new DropTable(defaultSchema, testTableName));
}
dataContext.executeUpdate(new CreateTable(defaultSchema, testTableName).withColumn("mykey")
.ofType(ColumnType.INTEGER).nullable(false).asPrimaryKey().withColumn("name")
.ofType(ColumnType.STRING).ofSize(20));
try {
final Table table = defaultSchema.getTableByName(testTableName);
assertNotNull(table);
// insert
dataContext.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.insertInto(table).value("mykey", 1).value("name", "Apache").execute();
callback.insertInto(table).value("mykey", 2).value("name", "MetaModel").execute();
}
});
// update
dataContext.executeUpdate(new Update(table).value("name", "MM").where("mykey").eq(2));
DataSet ds = dataContext.query().from(table).selectAll().orderBy("mykey").execute();
assertTrue(ds.next());
assertEquals("Row[values=[1, Apache]]", ds.getRow().toString());
assertTrue(ds.next());
assertEquals("Row[values=[2, MM]]", ds.getRow().toString());
assertFalse(ds.next());
ds.close();
} finally {
// clean up after
dataContext.executeUpdate(new DropTable(defaultSchema, testTableName));
}
}
public static void compositeKeyCreation(JdbcDataContext dataContext, String testTableName) {
final Schema defaultSchema = dataContext.getDefaultSchema();
if (defaultSchema.getTableByName(testTableName) != null) {
// clean up before
dataContext.executeUpdate(new DropTable(defaultSchema, testTableName));
}
dataContext.executeUpdate(new CreateTable(defaultSchema, testTableName).withColumn("mykey1")
.ofType(ColumnType.INTEGER).nullable(false).asPrimaryKey().withColumn("mykey2")
.ofType(ColumnType.INTEGER).nullable(false).asPrimaryKey().withColumn("name")
.ofType(ColumnType.VARCHAR).ofSize(20));
try {
final Table table = defaultSchema.getTableByName(testTableName);
assertNotNull(table);
Column[] primaryKeys = table.getPrimaryKeys().toArray(new Column[table.getPrimaryKeys().size()]);
assertEquals(2, primaryKeys.length);
assertEquals("mykey1", primaryKeys[0].getName().toLowerCase());
assertEquals("mykey2", primaryKeys[1].getName().toLowerCase());
// insert two records with unique values on both keys
dataContext.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.insertInto(table).value("mykey1", 1).value("mykey2", 100).value("name", "Apache")
.execute();
callback.insertInto(table).value("mykey1", 2).value("mykey2", 101).value("name", "MetaModel")
.execute();
}
});
// insert a record with non-unique value on key 2 only
dataContext.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.insertInto(table).value("mykey1", 3).value("mykey2", 100).value("name", "Foo bar")
.execute();
}
});
// update
dataContext.executeUpdate(new Update(table).value("name", "MM").where("mykey1").eq(2));
DataSet ds = dataContext.query().from(table).selectAll().orderBy("mykey1").execute();
assertTrue(ds.next());
assertEquals("Row[values=[1, 100, Apache]]", ds.getRow().toString());
assertTrue(ds.next());
assertEquals("Row[values=[2, 101, MM]]", ds.getRow().toString());
assertTrue(ds.next());
assertEquals("Row[values=[3, 100, Foo bar]]", ds.getRow().toString());
assertFalse(ds.next());
ds.close();
} finally {
// clean up after
dataContext.executeUpdate(new DropTable(defaultSchema, testTableName));
}
}
/**
*
* @param conn
* @param databasePrecision
* the precision with which the database can handle timestamp
* values. Expected values: {@link TimeUnit#SECONDS},
* {@link TimeUnit#MILLISECONDS}, {@link TimeUnit#MICROSECONDS}
* or {@link TimeUnit#NANOSECONDS}.
*
* @throws Exception
*/
public static void timestampValueInsertSelect(Connection conn, TimeUnit databasePrecision) throws Exception {
timestampValueInsertSelect(conn, databasePrecision, null);
}
public static void timestampValueInsertSelect(Connection conn, TimeUnit databasePrecision, final String nativeType)
throws Exception {
assertNotNull(conn);
final Statement statement = conn.createStatement();
try {
// clean up, if nescesary
statement.execute("DROP TABLE test_table");
} catch (SQLException e) {
// do nothing
} finally {
FileHelper.safeClose(statement);
}
assertFalse(conn.isReadOnly());
JdbcDataContext dc = new JdbcDataContext(conn);
final Schema schema = dc.getDefaultSchema();
final Timestamp timestamp1;
switch (databasePrecision) {
case SECONDS:
timestamp1 = Timestamp.valueOf("2015-10-16 16:33:33");
break;
case MILLISECONDS:
timestamp1 = Timestamp.valueOf("2015-10-16 16:33:33.456");
break;
case MICROSECONDS:
timestamp1 = Timestamp.valueOf("2015-10-16 16:33:33.456001");
break;
case NANOSECONDS:
timestamp1 = Timestamp.valueOf("2015-10-16 16:33:33.456001234");
break;
default:
throw new UnsupportedOperationException("Unsupported database precision: " + databasePrecision);
}
final Timestamp timestamp2;
switch (databasePrecision) {
case SECONDS:
timestamp2 = Timestamp.valueOf("2015-10-16 16:33:34");
break;
case MILLISECONDS:
timestamp2 = Timestamp.valueOf("2015-10-16 16:33:34.683");
break;
case MICROSECONDS:
timestamp2 = Timestamp.valueOf("2015-10-16 16:33:34.683005");
break;
case NANOSECONDS:
timestamp2 = Timestamp.valueOf("2015-10-16 16:33:34.683005678");
break;
default:
throw new UnsupportedOperationException("Unsupported database precision: " + databasePrecision);
}
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback cb) {
TableCreationBuilder tableBuilder = cb.createTable(schema, "test_table");
tableBuilder.withColumn("id").ofType(ColumnType.INTEGER);
tableBuilder.withColumn("insertiontime").ofType(ColumnType.TIMESTAMP);
if (nativeType == null) {
tableBuilder.withColumn("insertiontime").ofType(ColumnType.TIMESTAMP);
} else {
tableBuilder.withColumn("insertiontime").ofType(ColumnType.TIMESTAMP).ofNativeType(nativeType);
}
Table table = tableBuilder.execute();
cb.insertInto(table).value("id", 1).value("insertiontime", timestamp1).execute();
cb.insertInto(table).value("id", 2).value("insertiontime", timestamp2).execute();
}
});
DataSet ds = dc.query().from("test_table").select("id").and("insertiontime").execute();
assertTrue(ds.next());
switch (databasePrecision) {
case SECONDS:
assertEquals("Row[values=[1, 2015-10-16 16:33:33]]", ds.getRow().toString());
break;
case MILLISECONDS:
assertEquals("Row[values=[1, 2015-10-16 16:33:33.456]]", ds.getRow().toString());
break;
case MICROSECONDS:
assertEquals("Row[values=[1, 2015-10-16 16:33:33.456001]]", ds.getRow().toString());
break;
case NANOSECONDS:
assertEquals("Row[values=[1, 2015-10-16 16:33:33.456001234]]", ds.getRow().toString());
break;
default:
throw new UnsupportedOperationException("Unsupported database precision: " + databasePrecision);
}
assertTrue(ds.getRow().getValue(0) instanceof Number);
assertTrue(ds.next());
switch (databasePrecision) {
case SECONDS:
assertEquals("Row[values=[2, 2015-10-16 16:33:34]]", ds.getRow().toString());
break;
case MILLISECONDS:
assertEquals("Row[values=[2, 2015-10-16 16:33:34.683]]", ds.getRow().toString());
break;
case MICROSECONDS:
assertEquals("Row[values=[2, 2015-10-16 16:33:34.683005]]", ds.getRow().toString());
break;
case NANOSECONDS:
assertEquals("Row[values=[2, 2015-10-16 16:33:34.683005678]]", ds.getRow().toString());
break;
default:
throw new UnsupportedOperationException("Unsupported database precision: " + databasePrecision);
}
assertFalse(ds.next());
ds.close();
if (databasePrecision != TimeUnit.SECONDS) {
Query query = dc.query().from("test_table").select("id").where("insertiontime").lessThan(timestamp2)
.toQuery();
try {
ds = dc.executeQuery(query);
} catch (Exception e) {
System.out.println("Failing query was: " + dc.getQueryRewriter().rewriteQuery(query));
throw e;
}
assertTrue(ds.next());
assertEquals("Row[values=[1]]", ds.getRow().toString());
assertFalse(ds.next());
ds.close();
ds = dc.query().from("test_table").select("id").where("insertiontime").greaterThan(timestamp1).execute();
assertTrue(ds.next());
assertEquals("Row[values=[2]]", ds.getRow().toString());
assertFalse(ds.next());
ds.close();
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.deleteFrom("test_table").where("insertiontime").eq(timestamp1).execute();
}
});
ds = dc.query().from("test_table").selectCount().execute();
assertTrue(ds.next());
assertEquals("Row[values=[1]]", ds.getRow().toString());
assertFalse(ds.next());
ds.close();
}
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.dropTable("test_table").execute();
}
});
}
}
|
googleapis/google-cloud-java | 36,337 | java-analytics-admin/proto-google-analytics-admin-v1alpha/src/main/java/com/google/analytics/admin/v1alpha/UpdateCalculatedMetricRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/analytics/admin/v1alpha/analytics_admin.proto
// Protobuf Java Version: 3.25.8
package com.google.analytics.admin.v1alpha;
/**
*
*
* <pre>
* Request message for UpdateCalculatedMetric RPC.
* </pre>
*
* Protobuf type {@code google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest}
*/
public final class UpdateCalculatedMetricRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest)
UpdateCalculatedMetricRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateCalculatedMetricRequest.newBuilder() to construct.
private UpdateCalculatedMetricRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateCalculatedMetricRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateCalculatedMetricRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateCalculatedMetricRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateCalculatedMetricRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest.class,
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest.Builder.class);
}
private int bitField0_;
public static final int CALCULATED_METRIC_FIELD_NUMBER = 1;
private com.google.analytics.admin.v1alpha.CalculatedMetric calculatedMetric_;
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the calculatedMetric field is set.
*/
@java.lang.Override
public boolean hasCalculatedMetric() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The calculatedMetric.
*/
@java.lang.Override
public com.google.analytics.admin.v1alpha.CalculatedMetric getCalculatedMetric() {
return calculatedMetric_ == null
? com.google.analytics.admin.v1alpha.CalculatedMetric.getDefaultInstance()
: calculatedMetric_;
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.analytics.admin.v1alpha.CalculatedMetricOrBuilder
getCalculatedMetricOrBuilder() {
return calculatedMetric_ == null
? com.google.analytics.admin.v1alpha.CalculatedMetric.getDefaultInstance()
: calculatedMetric_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getCalculatedMetric());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getCalculatedMetric());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.analytics.admin.v1alpha.UpdateCalculatedMetricRequest)) {
return super.equals(obj);
}
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest other =
(com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest) obj;
if (hasCalculatedMetric() != other.hasCalculatedMetric()) return false;
if (hasCalculatedMetric()) {
if (!getCalculatedMetric().equals(other.getCalculatedMetric())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasCalculatedMetric()) {
hash = (37 * hash) + CALCULATED_METRIC_FIELD_NUMBER;
hash = (53 * hash) + getCalculatedMetric().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseFrom(
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest 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.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest 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.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest 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.analytics.admin.v1alpha.UpdateCalculatedMetricRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest 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.analytics.admin.v1alpha.UpdateCalculatedMetricRequest 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;
}
/**
*
*
* <pre>
* Request message for UpdateCalculatedMetric RPC.
* </pre>
*
* Protobuf type {@code google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest)
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateCalculatedMetricRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateCalculatedMetricRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest.class,
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest.Builder.class);
}
// Construct using com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getCalculatedMetricFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
calculatedMetric_ = null;
if (calculatedMetricBuilder_ != null) {
calculatedMetricBuilder_.dispose();
calculatedMetricBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.analytics.admin.v1alpha.AnalyticsAdminProto
.internal_static_google_analytics_admin_v1alpha_UpdateCalculatedMetricRequest_descriptor;
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest
getDefaultInstanceForType() {
return com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest build() {
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest buildPartial() {
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest result =
new com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.calculatedMetric_ =
calculatedMetricBuilder_ == null ? calculatedMetric_ : calculatedMetricBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.analytics.admin.v1alpha.UpdateCalculatedMetricRequest) {
return mergeFrom((com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest other) {
if (other
== com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest.getDefaultInstance())
return this;
if (other.hasCalculatedMetric()) {
mergeCalculatedMetric(other.getCalculatedMetric());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(
getCalculatedMetricFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.analytics.admin.v1alpha.CalculatedMetric calculatedMetric_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.analytics.admin.v1alpha.CalculatedMetric,
com.google.analytics.admin.v1alpha.CalculatedMetric.Builder,
com.google.analytics.admin.v1alpha.CalculatedMetricOrBuilder>
calculatedMetricBuilder_;
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the calculatedMetric field is set.
*/
public boolean hasCalculatedMetric() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The calculatedMetric.
*/
public com.google.analytics.admin.v1alpha.CalculatedMetric getCalculatedMetric() {
if (calculatedMetricBuilder_ == null) {
return calculatedMetric_ == null
? com.google.analytics.admin.v1alpha.CalculatedMetric.getDefaultInstance()
: calculatedMetric_;
} else {
return calculatedMetricBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setCalculatedMetric(com.google.analytics.admin.v1alpha.CalculatedMetric value) {
if (calculatedMetricBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
calculatedMetric_ = value;
} else {
calculatedMetricBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setCalculatedMetric(
com.google.analytics.admin.v1alpha.CalculatedMetric.Builder builderForValue) {
if (calculatedMetricBuilder_ == null) {
calculatedMetric_ = builderForValue.build();
} else {
calculatedMetricBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeCalculatedMetric(
com.google.analytics.admin.v1alpha.CalculatedMetric value) {
if (calculatedMetricBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& calculatedMetric_ != null
&& calculatedMetric_
!= com.google.analytics.admin.v1alpha.CalculatedMetric.getDefaultInstance()) {
getCalculatedMetricBuilder().mergeFrom(value);
} else {
calculatedMetric_ = value;
}
} else {
calculatedMetricBuilder_.mergeFrom(value);
}
if (calculatedMetric_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearCalculatedMetric() {
bitField0_ = (bitField0_ & ~0x00000001);
calculatedMetric_ = null;
if (calculatedMetricBuilder_ != null) {
calculatedMetricBuilder_.dispose();
calculatedMetricBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.analytics.admin.v1alpha.CalculatedMetric.Builder
getCalculatedMetricBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getCalculatedMetricFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.analytics.admin.v1alpha.CalculatedMetricOrBuilder
getCalculatedMetricOrBuilder() {
if (calculatedMetricBuilder_ != null) {
return calculatedMetricBuilder_.getMessageOrBuilder();
} else {
return calculatedMetric_ == null
? com.google.analytics.admin.v1alpha.CalculatedMetric.getDefaultInstance()
: calculatedMetric_;
}
}
/**
*
*
* <pre>
* Required. The CalculatedMetric to update
* </pre>
*
* <code>
* .google.analytics.admin.v1alpha.CalculatedMetric calculated_metric = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.analytics.admin.v1alpha.CalculatedMetric,
com.google.analytics.admin.v1alpha.CalculatedMetric.Builder,
com.google.analytics.admin.v1alpha.CalculatedMetricOrBuilder>
getCalculatedMetricFieldBuilder() {
if (calculatedMetricBuilder_ == null) {
calculatedMetricBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.analytics.admin.v1alpha.CalculatedMetric,
com.google.analytics.admin.v1alpha.CalculatedMetric.Builder,
com.google.analytics.admin.v1alpha.CalculatedMetricOrBuilder>(
getCalculatedMetric(), getParentForChildren(), isClean());
calculatedMetric_ = null;
}
return calculatedMetricBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* Required. The list of fields to be updated. Omitted fields will not be
* updated. To replace the entire entity, use one path with the string "*" to
* match all fields.
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.analytics.admin.v1alpha.UpdateCalculatedMetricRequest)
}
// @@protoc_insertion_point(class_scope:google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest)
private static final com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest();
}
public static com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateCalculatedMetricRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateCalculatedMetricRequest>() {
@java.lang.Override
public UpdateCalculatedMetricRequest 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<UpdateCalculatedMetricRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateCalculatedMetricRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.analytics.admin.v1alpha.UpdateCalculatedMetricRequest
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
google/closure-templates | 36,527 | java/src/com/google/template/soy/internal/i18n/BidiUtils.java | /*
* Copyright 2009 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.template.soy.internal.i18n;
import com.google.common.annotations.VisibleForTesting;
import com.google.template.soy.data.Dir;
import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.lang.UProperty;
import com.ibm.icu.lang.UScript;
import com.ibm.icu.util.ULocale;
/**
* Utility functions for performing common Bidi tests on strings.
*
*/
public class BidiUtils {
/** Not instantiable. */
private BidiUtils() {}
/**
* A container class for Unicode formatting characters and for directionality string constants.
*/
static final class Format {
private Format() {} // Not instantiable.
/** Unicode "Left-To-Right Embedding" (LRE) character. */
public static final char LRE = '\u202A';
/** Unicode "Right-To-Left Embedding" (RLE) character. */
public static final char RLE = '\u202B';
/** Unicode "Pop Directional Formatting" (PDF) character. */
public static final char PDF = '\u202C';
/** Unicode "Left-To-Right Mark" (LRM) character. */
public static final char LRM = '\u200E';
/** Unicode "Right-To-Left Mark" (RLM) character. */
public static final char RLM = '\u200F';
// Holding also the String representation of LRM and RLM is useful for
// several applications.
public static final String LRM_STRING = Character.toString(LRM);
public static final String RLM_STRING = Character.toString(RLM);
}
/** Returns whether a locale, given as a string in the ICU syntax, is RTL. */
public static boolean isRtlLanguage(String locale) {
try {
return UScript.isRightToLeft(
UCharacter.getPropertyValueEnum(
UProperty.SCRIPT, ULocale.addLikelySubtags(new ULocale(locale)).getScript()));
} catch (IllegalArgumentException e) {
return false;
}
}
/** An object that estimates the directionality of a given string by various methods. */
@VisibleForTesting
static class DirectionalityEstimator {
// Internal static variables and constants.
/**
* The size of the bidi character class cache. The results of the UCharacter.getDirectionality()
* calls on the lowest DIR_TYPE_CACHE_SIZE codepoints are kept in an array for speed. The 0x700
* value is designed to leave all the European and Near Eastern languages in the cache. It can
* be reduced to 0x180, restricting the cache to the Western European languages.
*/
private static final int DIR_TYPE_CACHE_SIZE = 0x700;
/** The bidi character class cache. */
private static final byte[] DIR_TYPE_CACHE;
static {
DIR_TYPE_CACHE = new byte[DIR_TYPE_CACHE_SIZE];
for (int i = 0; i < DIR_TYPE_CACHE_SIZE; i++) {
DIR_TYPE_CACHE[i] = UCharacter.getDirectionality(i);
}
}
/**
* The current classification of a word, for the word count direction estimation algorithm. As
* we progress our examination through a word, the type may increase in value e.g.: NEUTRAL ->
* EN | AN -> STRONG or NEUTRAL -> PLUS -> SIGNED_EN | PLUS_AN -> STRONG. It will only decrease
* when going back down to NEUTRAL at a word break, and when a neutral character (other than a
* plus or minus sign) appears after a plus or minus sign. Please note that STRONG, URL, and
* EMBEDDED are terminal, i.e. do not change into another word type until the end of the word is
* reached.
*/
private static class WordType {
/** Word so far - if any - contains no LTR, RTL, or numeric characters. */
public static final int NEUTRAL = 0;
/** Word so far is a plus sign. */
public static final int PLUS = 1;
/** Word so far is a minus sign. */
public static final int MINUS = 2;
/**
* Word so far started with a European numeral, and had no LTR or RTL or plus/minus before the
* number; enWordCount has been incremented.
*/
public static final int EN = 3;
/**
* Word so far started with an Arabic numeral, and had no LTR or RTL or plus/minus before the
* number.
*/
public static final int AN = 4;
/**
* Word so far has been a signed European number, which has to be displayed in LTR;
* signedEnWordCount has been incremented.
*/
public static final int SIGNED_EN = 5;
/**
* Word so far has been an Arabic number with a leading plus sign, which we may choose to
* interpret as an international phone number, which has to be displayed in LTR;
* plusAnWordCount has been incremented.
*/
public static final int PLUS_AN = 6;
/**
* Word so far has been a negative Arabic number, which has to be displayed in RTL;
* minusAnWordCount has been incremented.
*/
public static final int MINUS_AN = 7;
/** Word had an LTR or RTL character; ltrWordCount or rtlWordCount has been incremented. */
public static final int STRONG = 8;
/**
* Word started with a URL prefix (http:// or https://); urlWordCount has been incremented.
*/
public static final int URL = 9;
/** A "word" between LRE/LRO/RLE/RLO and matching PDF. */
public static final int EMBEDDED = 10;
}
/**
* If at least RTL_THRESHOLD of the words containing strong LTR or RTL in the string start with
* RTL, the word count direction estimation algorithm judges the string as a whole to be RTL.
*/
private static final double RTL_THRESHOLD = 0.4;
// Internal instance variables.
/** The text to be scanned. */
private final String text;
/**
* Whether the text to be scanned is to be treated as HTML, i.e. skipping over tags and entities
* when looking for the next / preceding dir type.
*/
private final boolean isHtml;
/** The length of the text in chars. */
private final int length;
/** The current position in the text. */
private int charIndex;
/**
* The char encountered by the last dirTypeForward or dirTypeBackward call. If it encountered a
* supplementary codepoint, this contains a char that is not a valid codepoint. This is ok,
* because this member is only used to detect some well-known ASCII syntax, e.g. "http://" and
* the beginning of an HTML tag or entity.
*/
private char lastChar;
/** Number of LTR words found so far by the word count direction estimation algorithm. */
private int ltrWordCount;
/** Number of RTL words found so far by the word count direction estimation algorithm. */
private int rtlWordCount;
/** Number of URLs found so far by the word count direction estimation algorithm. */
private int urlWordCount;
/**
* Number of unsigned EN numbers found so far by the word count direction estimation algorithm.
*/
private int enWordCount;
/**
* Number of signed EN numbers found so far by the word count direction estimation algorithm.
*/
private int signedEnWordCount;
/**
* Number of plus-signed AN numbers found so far by the word count direction estimation
* algorithm.
*/
private int plusAnWordCount;
/**
* Number of minus-signed AN numbers found so far by the word count direction estimation
* algorithm.
*/
private int minusAnWordCount;
/**
* Type (so far) of the word continuing at charIndex in the string, for the word count direction
* estimation algorithm.
*/
private int wordType;
// Methods intended for use by BidiUtils.
/**
* Constructor.
*
* @param text The string to scan.
* @param isHtml Whether the text to be scanned is to be treated as HTML, i.e. skipping over
* tags and entities.
*/
DirectionalityEstimator(String text, boolean isHtml) {
this.text = text;
this.isHtml = isHtml;
length = text.length();
}
/**
* Returns the directionality of the last character with strong directionality in the string, or
* Dir.NEUTRAL if none was encountered. For efficiency, actually scans backwards from the end of
* the string. Treats a non-BN character between an LRE/RLE/LRO/RLO and its matching PDF as a
* strong character, LTR after LRE/LRO, and RTL after RLE/RLO. The results are undefined for a
* string containing unbalanced LRE/RLE/LRO/RLO/PDF characters.
*/
Dir getExitDir() {
// The reason for this method name, as opposed to getLastStrongDir(), is that "last strong"
// sounds like the exact opposite of "first strong", which is a commonly used description of
// Unicode's estimation algorithm (getUnicodeDir() above), but the two must treat formatting
// characters quite differently. Thus, we are staying away from both "first" and "last" in
// these method names to avoid confusion.
charIndex = length;
int embeddingLevel = 0;
int lastNonEmptyEmbeddingLevel = 0;
while (charIndex > 0) {
switch (dirTypeBackward()) {
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT:
if (embeddingLevel == 0) {
return Dir.LTR;
}
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
return Dir.LTR;
}
--embeddingLevel;
break;
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT:
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
if (embeddingLevel == 0) {
return Dir.RTL;
}
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
return Dir.RTL;
}
--embeddingLevel;
break;
case UCharacter.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
++embeddingLevel;
break;
case UCharacter.BOUNDARY_NEUTRAL:
break;
default:
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
}
}
return Dir.NEUTRAL;
}
/**
* Estimates the directionality of the (whole) string based on relative word counts. See {@link
* #estimateDirection(String, boolean)} for full description.
*
* @return the string's directionality
*/
@SuppressWarnings("fallthrough")
Dir estimateDirectionByWordCount() {
charIndex = 0;
ltrWordCount = 0;
rtlWordCount = 0;
urlWordCount = 0;
enWordCount = 0;
signedEnWordCount = 0;
plusAnWordCount = 0;
minusAnWordCount = 0;
int embedLevel = 0;
wordType = WordType.NEUTRAL;
while (charIndex < length) {
byte dirType = dirTypeForward();
// The DIRECTIONALITY_LEFT_TO_RIGHT case is taken out of the switch statement below to
// improve the performance for LTR text (i.e. the vast majority of the content encountered
// on the web).
if (dirType == UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT) {
// Strongly LTR. Convert numeric word to LTR, and a neutral word either to LTR or, if
// the character just scanned and the characters following it are a URL, to a URL.
processStrong(/* isRtl= */ false);
} else {
switch (dirType) {
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT:
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
// Strongly RTL. Convert neutral or numeric word to RTL.
processStrong(/* isRtl= */ true);
break;
case UCharacter.DIRECTIONALITY_EUROPEAN_NUMBER:
// A European digit. Convert NEUTRAL to EN, and PLUS and MINUS to SIGNED_EN.
processEuropeanDigit();
break;
case UCharacter.DIRECTIONALITY_ARABIC_NUMBER:
// An Arabic digit. Convert NEUTRAL to AN, PLUS to PLUS_AN, and MINUS to MINUS_AN.
processArabicDigit();
break;
case UCharacter.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR:
// Plus or minus sign. Treat as end of a numeric word, and convert NEUTRAL to PLUS or
// MINUS.
if (wordType < WordType.STRONG) {
if (wordType <= WordType.MINUS) {
switch (lastChar) {
case 0x002B: // PLUS SIGN
case 0x207A: // SUPERSCRIPT PLUS SIGN
case 0x208A: // SUBSCRIPT PLUS SIGN
case 0xFB29: // HEBREW LETTER ALTERNATIVE PLUS SIGN
case 0xFE62: // SMALL PLUS SIGN
case 0xFF0B: // FULLWIDTH PLUS SIGN
wordType = WordType.PLUS;
break;
default:
wordType = WordType.MINUS;
break;
}
} else {
wordType = WordType.NEUTRAL;
}
}
break;
case UCharacter.COMMON_NUMBER_SEPARATOR:
// Neutral used to format numbers that (with the exception of a slash, due to a
// Microsoft bug) can be relied upon to keep the digits around it displayed LTR. Reset
// PLUS and MINUS back to NEUTRAL, and treat a slash as the end of a numeric word.
if (wordType < WordType.STRONG && (wordType <= WordType.MINUS || lastChar == '/')) {
wordType = WordType.NEUTRAL;
}
break;
case UCharacter.OTHER_NEUTRAL:
case UCharacter.EUROPEAN_NUMBER_TERMINATOR:
// Neutrals not used for formatting inside numbers. Treat as end of a numeric word.
if (wordType < WordType.STRONG) {
wordType = WordType.NEUTRAL;
}
break;
case UCharacter.DIRECTIONALITY_WHITESPACE:
case UCharacter.DIRECTIONALITY_SEGMENT_SEPARATOR:
// Whitespace. Treat as end of word, unless embedded.
if (wordType < WordType.EMBEDDED) {
wordType = WordType.NEUTRAL;
}
break;
case UCharacter.DIRECTIONALITY_PARAGRAPH_SEPARATOR:
// Paragraph break. Treat as end of word, and reset embedding level.
embedLevel = 0;
wordType = WordType.NEUTRAL;
break;
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
// LRO overrides the directionality of the characters inside it, so treat them as
// strongly LTR.
processStrong(/* isRtl= */ false);
// Fall through to LRE processing.
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
// Start LTR embedded area.
if (embedLevel++ == 0) {
wordType = WordType.EMBEDDED;
}
break;
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
// RLO overrides the directionality of the characters inside it, so treat them as
// a strongly RTL word.
processStrong(/* isRtl= */ true);
// Fall through to RLE processing.
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
// Start RTL embedded area.
if (embedLevel++ == 0) {
wordType = WordType.EMBEDDED;
}
break;
case UCharacter.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
// End embedded area.
if (--embedLevel == 0) {
wordType = WordType.NEUTRAL;
}
break;
default:
// Ignore control characters (DIRECTIONALITY_BOUNDARY_NEUTRAL) and non-spacing marks
// (DIRECTIONALITY_NON_SPACING_MARKS).
break;
}
}
}
return compareCounts();
}
// Internal methods
/*
* Make the final choice of estimated direction depending on the calculated word counts.
*/
Dir compareCounts() {
if (rtlWordCount > (ltrWordCount + rtlWordCount) * RTL_THRESHOLD) {
return Dir.RTL;
}
// If ltrWordCount is greater than zero, the string is LTR. Otherwise, rtlWordCount must also
// be zero, and the result depends only on the "weak" words - URLs and numbers.
if (ltrWordCount + urlWordCount + signedEnWordCount > 0 || enWordCount > 1) {
return Dir.LTR;
}
if (minusAnWordCount > 0) {
return Dir.RTL;
}
if (plusAnWordCount > 0) {
return Dir.LTR;
}
return Dir.NEUTRAL;
}
/**
* Converts a neutral or numeric word to STRONG, or, if the word had been neutral, and the
* character just scanned and the characters following are a URL, to a URL, and adjusts the word
* counts appropriately.
*/
private void processStrong(boolean isRtl) {
if (wordType >= WordType.STRONG) {
// Current word's type is final.
return;
}
switch (wordType) {
case WordType.NEUTRAL:
if (!isRtl
&& lastChar == 'h'
&& (matchForward("ttp://", true) || matchForward("ttps://", true))) {
// This is the start of a URL.
wordType = WordType.URL;
++urlWordCount;
return;
}
break;
case WordType.SIGNED_EN:
// signedEnWordCount was incremented earlier; revert it.
--signedEnWordCount;
break;
case WordType.PLUS_AN:
// plusAnWordCount was incremented earlier; revert it.
--plusAnWordCount;
break;
case WordType.MINUS_AN:
// minusAnWordCount was incremented earlier; revert it.
--minusAnWordCount;
break;
case WordType.EN:
// enWordCount was incremented earlier; revert it.
--enWordCount;
break;
default:
// No word count was incremented earlier.
break;
}
wordType = WordType.STRONG;
if (isRtl) {
++rtlWordCount;
} else {
++ltrWordCount;
}
}
/**
* Converts a NEUTRAL to EN, and PLUS and MINUS to SIGNED_EN, and adjusts the word counts
* appropriately.
*/
private void processEuropeanDigit() {
switch (wordType) {
case WordType.NEUTRAL:
// Convert a neutral word to an unsigned "European" number.
++enWordCount;
wordType = WordType.EN;
break;
case WordType.PLUS:
case WordType.MINUS:
// Convert a sign to a signed "European" number.
++signedEnWordCount;
wordType = WordType.SIGNED_EN;
break;
default:
break;
}
}
/**
* Converts a NEUTRAL to AN, PLUS to PLUS_AN, and MINUS to MINUS_AN, and adjusts the word counts
* appropriately.
*/
private void processArabicDigit() {
switch (wordType) {
case WordType.NEUTRAL:
// Convert a neutral word to an unsigned "Arabic" number. Currently, unsigned "Arabic"
// numbers do not play a part in deciding the overall directionality. Nevertheless, we
// do identify them here so we can easily change the policy on them if necessary.
wordType = WordType.AN;
break;
case WordType.PLUS:
// Convert a plus sign to a plus-signed "Arabic" number.
++plusAnWordCount;
wordType = WordType.PLUS_AN;
break;
case WordType.MINUS:
// Convert a minus sign to a minus-signed "Arabic" number.
++minusAnWordCount;
wordType = WordType.MINUS_AN;
break;
default:
break;
}
}
/**
* Returns whether the text at charIndex going forward is equal to a given string. Does NOT skip
* over HTML mark-up.
*
* @param match The string to match.
* @param advance Whether to advance charIndex to the end of a successful match.
* @return Whether the text at charIndex going forward is equal to the given string.
*/
@VisibleForTesting
boolean matchForward(String match, boolean advance) {
int matchLength = match.length();
if (matchLength > length - charIndex) {
return false;
}
for (int checkIndex = 0; checkIndex < matchLength; checkIndex++) {
if (text.charAt(charIndex + checkIndex) != match.charAt(checkIndex)) {
return false;
}
}
if (advance) {
charIndex += matchLength;
}
return true;
}
/**
* Gets the bidi character class, i.e. UCharacter.getDirectionality(), of a given char, using a
* cache for speed. Not designed for supplementary codepoints, whose results we do not cache.
*/
private static byte getCachedDirectionality(char c) {
return c < DIR_TYPE_CACHE_SIZE ? DIR_TYPE_CACHE[c] : UCharacter.getDirectionality(c);
}
/**
* Returns the UCharacter.DIRECTIONALITY_... value of the next codepoint and advances charIndex.
* If isHtml, and the codepoint is '<' or '&', advances through the tag/entity, and returns an
* appropriate dirtype.
*
* @throws java.lang.IndexOutOfBoundsException if called when charIndex >= length or < 0.
*/
@VisibleForTesting
byte dirTypeForward() {
lastChar = text.charAt(charIndex);
if (UCharacter.isHighSurrogate(lastChar)) {
int codePoint = UCharacter.codePointAt(text, charIndex);
charIndex += UCharacter.charCount(codePoint);
return UCharacter.getDirectionality(codePoint);
}
charIndex++;
byte dirType = getCachedDirectionality(lastChar);
if (isHtml) {
// Process tags and entities.
if (lastChar == '<') {
dirType = skipTagForward();
} else if (lastChar == '&') {
dirType = skipEntityForward();
}
}
return dirType;
}
/**
* Returns the UCharacter.DIRECTIONALITY_... value of the preceding codepoint and advances
* charIndex backwards. If isHtml, and the codepoint is the end of a complete HTML tag or
* entity, advances over the whole tag/entity and returns an appropriate dirtype.
*
* @throws java.lang.IndexOutOfBoundsException if called when charIndex > length or <= 0.
*/
@VisibleForTesting
byte dirTypeBackward() {
lastChar = text.charAt(charIndex - 1);
if (UCharacter.isLowSurrogate(lastChar)) {
int codePoint = UCharacter.codePointBefore(text, charIndex);
charIndex -= UCharacter.charCount(codePoint);
return UCharacter.getDirectionality(codePoint);
}
charIndex--;
byte dirType = getCachedDirectionality(lastChar);
if (isHtml) {
// Process tags and entities.
if (lastChar == '>') {
dirType = skipTagBackward();
} else if (lastChar == ';') {
dirType = skipEntityBackward();
}
}
return dirType;
}
/**
* Advances charIndex forward through an HTML tag (after the opening < has already been read)
* and returns an appropriate dirtype for the tag. If there is no matching >, does not change
* charIndex and returns UCharacter.DIRECTIONALITY_OTHER_NEUTRALS (for the < that hadn't been
* part of a tag after all).
*/
private byte skipTagForward() {
int initialCharIndex = charIndex;
while (charIndex < length) {
lastChar = text.charAt(charIndex++);
if (lastChar == '>') {
// The end of the tag.
// We return BN because the tags we really expect to encounter - and know how to handle
// best - are inline ones like <span>, <b>, <i>, <a>, etc. These do not connote a word
// break (as would WS) or punctuation (as would ON), but really are most similar to
// control codes. Ideally, we should check the actual tag and return B for <br> and the
// block element tags, but perfecting handling of multi-paragraph input isn't very
// important since estimating one directionality over several paragraphs is futile anyway:
// each one should be allowed its own. More importantly, we should check for the dir
// attribute and return an appropriate embedding, override, or isolate initiator bidi
// class, and its closing dirtype for the closing tag, but finding the closing tag is
// not so easy. A poor man's approach that should be good enough without needing a stack
// could ignore the dir attribute on elements nested in an element with a dir attribute,
// and find its closing tag by counting the nesting only of its type. Still, this wouldn't
// work in skipTagBackward() - see note there.
// TODO(user): Consider checking the tag and returning BN, B, or one of the explicit
// directional formatting dirtypes, as appropriate.
return UCharacter.DIRECTIONALITY_BOUNDARY_NEUTRAL;
}
if (lastChar == '"' || lastChar == '\'') {
// Skip over a quoted attribute value inside the tag.
char quote = lastChar;
while (charIndex < length && (lastChar = text.charAt(charIndex++)) != quote) {}
}
}
// The original '<' wasn't the start of a tag after all.
charIndex = initialCharIndex;
lastChar = '<';
return UCharacter.DIRECTIONALITY_OTHER_NEUTRALS;
}
/**
* Advances charIndex backward through an HTML tag (after the closing > has already been
* read) and returns an appropriate dirtype for the tag. If there is no matching <, does not
* change charIndex and returns UCharacter.DIRECTIONALITY_OTHER_NEUTRALS (for the > that
* hadn't been part of a tag after all). Nevertheless, the running time for calling
* skipTagBackward() in a loop remains linear in the size of the text, even for a text like
* ">>>>", because skipTagBackward() also stops looking for a matching < when it
* encounters another >.
*/
private byte skipTagBackward() {
int initialCharIndex = charIndex;
while (charIndex > 0) {
lastChar = text.charAt(--charIndex);
if (lastChar == '<') {
// The start of the tag. See note in skipTagForward() regarding the dirtype we return.
// Note, however, that the "poor man's approach" described there for handling the dir
// attribute wouldn't work here, since here we see the closing tag first - and do not
// have any indication if its matching opening tag carries the dir attribute.
return UCharacter.DIRECTIONALITY_BOUNDARY_NEUTRAL;
}
if (lastChar == '>') {
break;
}
if (lastChar == '"' || lastChar == '\'') {
// Skip over a quoted attribute value inside the tag.
char quote = lastChar;
while (charIndex > 0 && (lastChar = text.charAt(--charIndex)) != quote) {}
}
}
// The original '>' wasn't the end of a tag after all.
charIndex = initialCharIndex;
lastChar = '>';
return UCharacter.DIRECTIONALITY_OTHER_NEUTRALS;
}
/**
* Advances charIndex forward through an HTML character entity tag (after the opening & has
* already been read) and returns UCharacter.DIRECTIONALITY_WHITESPACE. It would be best to
* figure out the actual character and return its dirtype, but this is good enough.
*/
private byte skipEntityForward() {
while (charIndex < length && (lastChar = text.charAt(charIndex++)) != ';') {}
return UCharacter.DIRECTIONALITY_WHITESPACE;
}
/**
* Advances charIndex backward through an HTML character entity tag (after the closing ; has
* already been read) and returns UCharacter.DIRECTIONALITY_WHITESPACE. It would be best to
* figure out the actual character and return its dirtype, but this is good enough. If there is
* no matching &, does not change charIndex and returns
* UCharacter.DIRECTIONALITY_OTHER_NEUTRALS (for the ';' that did not start an entity after
* all). Nevertheless, the running time for calling skipEntityBackward() in a loop remains
* linear in the size of the text, even for a text like ";;;;;;;", because skipTagBackward()
* also stops looking for a matching & when it encounters another ;.
*/
private byte skipEntityBackward() {
int initialCharIndex = charIndex;
while (charIndex > 0) {
lastChar = text.charAt(--charIndex);
if (lastChar == '&') {
return UCharacter.DIRECTIONALITY_WHITESPACE;
}
if (lastChar == ';') {
break;
}
}
charIndex = initialCharIndex;
lastChar = ';';
return UCharacter.DIRECTIONALITY_OTHER_NEUTRALS;
}
}
/**
* Returns the directionality of the last character with strong directionality in the string, or
* Dir.NEUTRAL if none was encountered. For efficiency, actually scans backwards from the end of
* the string. Treats a non-BN character between an LRE/RLE/LRO/RLO and its matching PDF as a
* strong character, LTR after LRE/LRO, and RTL after RLE/RLO. The results are undefined for a
* string containing unbalanced LRE/RLE/LRO/RLO/PDF characters. The intended use is to check
* whether a logically separate item that starts with a number or a character of the string's exit
* directionality and follows this string inline (not counting any neutral characters in between)
* would "stick" to it in an opposite-directionality context, thus being displayed in an incorrect
* position. An LRM or RLM character (the one of the context's directionality) between the two
* will prevent such sticking.
*
* @param str the string to check
* @param isHtml whether str is HTML / HTML-escaped
*/
public static Dir getExitDir(String str, boolean isHtml) {
return new DirectionalityEstimator(str, isHtml).getExitDir();
}
/**
* Estimates the directionality of a string based on relative word counts, as detailed below.
*
* <p>The parts of the text embedded between LRE/RLE and the matching PDF are ignored, since the
* directionality in which the string as a whole is displayed will not affect their display
* anyway, and we want to base it on the remainder.
*
* <p>The parts of the text embedded between LRO/RLO and the matching PDF are considered LTR/RTL
* "words". This is primarily in order to treat "fake bidi" pseudolocalized text as RTL.
*
* <p>The remaining parts of the text are divided into "words" on whitespace and, inside numbers,
* on neutral characters that break the LTR flow around them when used inside a number in an RTL
* context. (This is most of them, the primary exceptions being period, comma, NBSP and colon,
* i.e. bidi class CS not including slash, which a long-standing Microsoft bug treats as ES)).
*
* <p>Each word is assigned a type - LTR, RTL, URL, signed "European" number, unsigned "European"
* number, negative "Arabic" number, "Arabic" number with leading plus sign, and unsigned "Arabic"
* number - as follows:
*
* <p>- Words that start with "http[s]://" (possibly preceded by some neutrals) are URLs.
*
* <p>- Of the remaining words, those that contain any strongly directional characters are
* classified as LTR or RTL based on their first strongly directional character.
*
* <p>- Of the remaining words, those that contain any digits are classified as an "European" or
* "Arabic" number based on the type of its first digit, and signed or unsigned depending on
* whether the first digit was immediately preceded by a plus or minus sign (bidi class ES).
*
* <p>- The remaining words are classified as "neutral" and ignored.
*
* <p>Once the words of each type have been counted, the directionality is decided as follows:
*
* <p>If the number of RTL words exceeds 40% of the total of LTR and RTL words, return Dir.RTL.
* The threshold favors RTL because LTR words and phrases are used in RTL sentences more commonly
* than RTL in LTR.
*
* <p>Otherwise, if there are any LTR words, return Dir.LTR.
*
* <p>Otherwise (i.e. if there are no LTR or RTL words), if there are any URLs, or any signed
* "European" numbers, or an "Arabic" number with a leading plus sign, or more than one unsigned
* "European" number, return Dir.LTR. This ensures that the text is displayed LTR even in an RTL
* context, where things like "http://www.google.com/", "-5", "+١٢٣٤٢٣٤٦٧٨٩" (assuming it is
* intended as an international phone number, not an explicitly signed positive number, which is a
* very rare use case), "3 - 2 = 1", "(03) 123 4567", and, when preceded by an Arabic letter, even
* "123-4567" and "400×300" are displayed incorrectly. (Most neutrals, including those in the last
* two examples, are treated as ending a number in order to treat such expressions as containing
* more than one "European" number, and thus to force their display in LTR.) Considering a string
* containing more than "European" number to be LTR also makes sense because math expressions in
* "European" digits need to be displayed LTR even in RTL languages. However, that probably isn't
* a very important consideration, since math expressions would usually also contain strongly LTR
* or RTL variable names that should set the overall directionality. Ranges like "$1 - $5" *are*
* an important consideration, but their preferred direction unfortunately varies among the RTL
* languages. Since LTR is preferred for ranges in Persian and Urdu, and is the more widespread
* usage in Hebrew, it seems like an OK choice. Please note that native Persian digits are
* included in the "European" class because the unary minus is preferred on the left in Persian,
* and Persian math is written LTR.
*
* <p>Otherwise, if there are any negative "Arabic" numbers, return Dir.RTL. This is because the
* unary minus is supposed to be displayed to the right of a number written in "Arabic" digits.
*
* <p>Otherwise, return Dir.NEUTRAL. This includes the common case of a single unsigned number,
* which will display correctly in either "European" or "Arabic" digits in either directionality,
* so it is best not to force it to either. It also includes an otherwise neutral string
* containing two or more "Arabic" numbers. We do *not* consider it to be RTL because it is
* unclear that it is important to display "Arabic"-digit math and ranges in RTL even in an LTR
* context, and because we have no idea how to handle phone numbers spelled (or, more likely,
* misspelled) in "Arabic" digits with non-CS separators. But it is quite clear that we do not
* want to force it to LTR.
*
* <p>If {@code isHtml} is true, treats {@code str} as HTML, ignoring HTML tags and escapes that
* would otherwise be mistaken for LTR text.
*
* @param str the string to check
* @param isHtml whether str is HTML / HTML-escaped
* @return the string's directionality
*/
public static Dir estimateDirection(String str, boolean isHtml) {
return new DirectionalityEstimator(str, isHtml).estimateDirectionByWordCount();
}
}
|
googleapis/google-cloud-java | 36,306 | java-chronicle/proto-google-cloud-chronicle-v1/src/main/java/com/google/cloud/chronicle/v1/ListRetrohuntsResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/chronicle/v1/rule.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.chronicle.v1;
/**
*
*
* <pre>
* Response message for ListRetrohunts method.
* </pre>
*
* Protobuf type {@code google.cloud.chronicle.v1.ListRetrohuntsResponse}
*/
public final class ListRetrohuntsResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.chronicle.v1.ListRetrohuntsResponse)
ListRetrohuntsResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListRetrohuntsResponse.newBuilder() to construct.
private ListRetrohuntsResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListRetrohuntsResponse() {
retrohunts_ = java.util.Collections.emptyList();
nextPageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListRetrohuntsResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.chronicle.v1.RuleProto
.internal_static_google_cloud_chronicle_v1_ListRetrohuntsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.chronicle.v1.RuleProto
.internal_static_google_cloud_chronicle_v1_ListRetrohuntsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.chronicle.v1.ListRetrohuntsResponse.class,
com.google.cloud.chronicle.v1.ListRetrohuntsResponse.Builder.class);
}
public static final int RETROHUNTS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.chronicle.v1.Retrohunt> retrohunts_;
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.chronicle.v1.Retrohunt> getRetrohuntsList() {
return retrohunts_;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.cloud.chronicle.v1.RetrohuntOrBuilder>
getRetrohuntsOrBuilderList() {
return retrohunts_;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
@java.lang.Override
public int getRetrohuntsCount() {
return retrohunts_.size();
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
@java.lang.Override
public com.google.cloud.chronicle.v1.Retrohunt getRetrohunts(int index) {
return retrohunts_.get(index);
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
@java.lang.Override
public com.google.cloud.chronicle.v1.RetrohuntOrBuilder getRetrohuntsOrBuilder(int index) {
return retrohunts_.get(index);
}
public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
@java.lang.Override
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
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();
nextPageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 {
for (int i = 0; i < retrohunts_.size(); i++) {
output.writeMessage(1, retrohunts_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < retrohunts_.size(); i++) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, retrohunts_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_);
}
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.chronicle.v1.ListRetrohuntsResponse)) {
return super.equals(obj);
}
com.google.cloud.chronicle.v1.ListRetrohuntsResponse other =
(com.google.cloud.chronicle.v1.ListRetrohuntsResponse) obj;
if (!getRetrohuntsList().equals(other.getRetrohuntsList())) return false;
if (!getNextPageToken().equals(other.getNextPageToken())) 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 (getRetrohuntsCount() > 0) {
hash = (37 * hash) + RETROHUNTS_FIELD_NUMBER;
hash = (53 * hash) + getRetrohuntsList().hashCode();
}
hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getNextPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse 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.chronicle.v1.ListRetrohuntsResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse 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.chronicle.v1.ListRetrohuntsResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse 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.chronicle.v1.ListRetrohuntsResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse 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.chronicle.v1.ListRetrohuntsResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse 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.chronicle.v1.ListRetrohuntsResponse 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;
}
/**
*
*
* <pre>
* Response message for ListRetrohunts method.
* </pre>
*
* Protobuf type {@code google.cloud.chronicle.v1.ListRetrohuntsResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.chronicle.v1.ListRetrohuntsResponse)
com.google.cloud.chronicle.v1.ListRetrohuntsResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.chronicle.v1.RuleProto
.internal_static_google_cloud_chronicle_v1_ListRetrohuntsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.chronicle.v1.RuleProto
.internal_static_google_cloud_chronicle_v1_ListRetrohuntsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.chronicle.v1.ListRetrohuntsResponse.class,
com.google.cloud.chronicle.v1.ListRetrohuntsResponse.Builder.class);
}
// Construct using com.google.cloud.chronicle.v1.ListRetrohuntsResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (retrohuntsBuilder_ == null) {
retrohunts_ = java.util.Collections.emptyList();
} else {
retrohunts_ = null;
retrohuntsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
nextPageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.chronicle.v1.RuleProto
.internal_static_google_cloud_chronicle_v1_ListRetrohuntsResponse_descriptor;
}
@java.lang.Override
public com.google.cloud.chronicle.v1.ListRetrohuntsResponse getDefaultInstanceForType() {
return com.google.cloud.chronicle.v1.ListRetrohuntsResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.chronicle.v1.ListRetrohuntsResponse build() {
com.google.cloud.chronicle.v1.ListRetrohuntsResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.chronicle.v1.ListRetrohuntsResponse buildPartial() {
com.google.cloud.chronicle.v1.ListRetrohuntsResponse result =
new com.google.cloud.chronicle.v1.ListRetrohuntsResponse(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.chronicle.v1.ListRetrohuntsResponse result) {
if (retrohuntsBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
retrohunts_ = java.util.Collections.unmodifiableList(retrohunts_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.retrohunts_ = retrohunts_;
} else {
result.retrohunts_ = retrohuntsBuilder_.build();
}
}
private void buildPartial0(com.google.cloud.chronicle.v1.ListRetrohuntsResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.nextPageToken_ = nextPageToken_;
}
}
@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.chronicle.v1.ListRetrohuntsResponse) {
return mergeFrom((com.google.cloud.chronicle.v1.ListRetrohuntsResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.chronicle.v1.ListRetrohuntsResponse other) {
if (other == com.google.cloud.chronicle.v1.ListRetrohuntsResponse.getDefaultInstance())
return this;
if (retrohuntsBuilder_ == null) {
if (!other.retrohunts_.isEmpty()) {
if (retrohunts_.isEmpty()) {
retrohunts_ = other.retrohunts_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureRetrohuntsIsMutable();
retrohunts_.addAll(other.retrohunts_);
}
onChanged();
}
} else {
if (!other.retrohunts_.isEmpty()) {
if (retrohuntsBuilder_.isEmpty()) {
retrohuntsBuilder_.dispose();
retrohuntsBuilder_ = null;
retrohunts_ = other.retrohunts_;
bitField0_ = (bitField0_ & ~0x00000001);
retrohuntsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getRetrohuntsFieldBuilder()
: null;
} else {
retrohuntsBuilder_.addAllMessages(other.retrohunts_);
}
}
}
if (!other.getNextPageToken().isEmpty()) {
nextPageToken_ = other.nextPageToken_;
bitField0_ |= 0x00000002;
onChanged();
}
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 10:
{
com.google.cloud.chronicle.v1.Retrohunt m =
input.readMessage(
com.google.cloud.chronicle.v1.Retrohunt.parser(), extensionRegistry);
if (retrohuntsBuilder_ == null) {
ensureRetrohuntsIsMutable();
retrohunts_.add(m);
} else {
retrohuntsBuilder_.addMessage(m);
}
break;
} // case 10
case 18:
{
nextPageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
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.chronicle.v1.Retrohunt> retrohunts_ =
java.util.Collections.emptyList();
private void ensureRetrohuntsIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
retrohunts_ = new java.util.ArrayList<com.google.cloud.chronicle.v1.Retrohunt>(retrohunts_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.chronicle.v1.Retrohunt,
com.google.cloud.chronicle.v1.Retrohunt.Builder,
com.google.cloud.chronicle.v1.RetrohuntOrBuilder>
retrohuntsBuilder_;
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public java.util.List<com.google.cloud.chronicle.v1.Retrohunt> getRetrohuntsList() {
if (retrohuntsBuilder_ == null) {
return java.util.Collections.unmodifiableList(retrohunts_);
} else {
return retrohuntsBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public int getRetrohuntsCount() {
if (retrohuntsBuilder_ == null) {
return retrohunts_.size();
} else {
return retrohuntsBuilder_.getCount();
}
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public com.google.cloud.chronicle.v1.Retrohunt getRetrohunts(int index) {
if (retrohuntsBuilder_ == null) {
return retrohunts_.get(index);
} else {
return retrohuntsBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder setRetrohunts(int index, com.google.cloud.chronicle.v1.Retrohunt value) {
if (retrohuntsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRetrohuntsIsMutable();
retrohunts_.set(index, value);
onChanged();
} else {
retrohuntsBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder setRetrohunts(
int index, com.google.cloud.chronicle.v1.Retrohunt.Builder builderForValue) {
if (retrohuntsBuilder_ == null) {
ensureRetrohuntsIsMutable();
retrohunts_.set(index, builderForValue.build());
onChanged();
} else {
retrohuntsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder addRetrohunts(com.google.cloud.chronicle.v1.Retrohunt value) {
if (retrohuntsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRetrohuntsIsMutable();
retrohunts_.add(value);
onChanged();
} else {
retrohuntsBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder addRetrohunts(int index, com.google.cloud.chronicle.v1.Retrohunt value) {
if (retrohuntsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureRetrohuntsIsMutable();
retrohunts_.add(index, value);
onChanged();
} else {
retrohuntsBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder addRetrohunts(com.google.cloud.chronicle.v1.Retrohunt.Builder builderForValue) {
if (retrohuntsBuilder_ == null) {
ensureRetrohuntsIsMutable();
retrohunts_.add(builderForValue.build());
onChanged();
} else {
retrohuntsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder addRetrohunts(
int index, com.google.cloud.chronicle.v1.Retrohunt.Builder builderForValue) {
if (retrohuntsBuilder_ == null) {
ensureRetrohuntsIsMutable();
retrohunts_.add(index, builderForValue.build());
onChanged();
} else {
retrohuntsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder addAllRetrohunts(
java.lang.Iterable<? extends com.google.cloud.chronicle.v1.Retrohunt> values) {
if (retrohuntsBuilder_ == null) {
ensureRetrohuntsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, retrohunts_);
onChanged();
} else {
retrohuntsBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder clearRetrohunts() {
if (retrohuntsBuilder_ == null) {
retrohunts_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
retrohuntsBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public Builder removeRetrohunts(int index) {
if (retrohuntsBuilder_ == null) {
ensureRetrohuntsIsMutable();
retrohunts_.remove(index);
onChanged();
} else {
retrohuntsBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public com.google.cloud.chronicle.v1.Retrohunt.Builder getRetrohuntsBuilder(int index) {
return getRetrohuntsFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public com.google.cloud.chronicle.v1.RetrohuntOrBuilder getRetrohuntsOrBuilder(int index) {
if (retrohuntsBuilder_ == null) {
return retrohunts_.get(index);
} else {
return retrohuntsBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public java.util.List<? extends com.google.cloud.chronicle.v1.RetrohuntOrBuilder>
getRetrohuntsOrBuilderList() {
if (retrohuntsBuilder_ != null) {
return retrohuntsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(retrohunts_);
}
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public com.google.cloud.chronicle.v1.Retrohunt.Builder addRetrohuntsBuilder() {
return getRetrohuntsFieldBuilder()
.addBuilder(com.google.cloud.chronicle.v1.Retrohunt.getDefaultInstance());
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public com.google.cloud.chronicle.v1.Retrohunt.Builder addRetrohuntsBuilder(int index) {
return getRetrohuntsFieldBuilder()
.addBuilder(index, com.google.cloud.chronicle.v1.Retrohunt.getDefaultInstance());
}
/**
*
*
* <pre>
* The retrohunts from the specified rule.
* </pre>
*
* <code>repeated .google.cloud.chronicle.v1.Retrohunt retrohunts = 1;</code>
*/
public java.util.List<com.google.cloud.chronicle.v1.Retrohunt.Builder>
getRetrohuntsBuilderList() {
return getRetrohuntsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.chronicle.v1.Retrohunt,
com.google.cloud.chronicle.v1.Retrohunt.Builder,
com.google.cloud.chronicle.v1.RetrohuntOrBuilder>
getRetrohuntsFieldBuilder() {
if (retrohuntsBuilder_ == null) {
retrohuntsBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.chronicle.v1.Retrohunt,
com.google.cloud.chronicle.v1.Retrohunt.Builder,
com.google.cloud.chronicle.v1.RetrohuntOrBuilder>(
retrohunts_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
retrohunts_ = null;
}
return retrohuntsBuilder_;
}
private java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
nextPageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearNextPageToken() {
nextPageToken_ = getDefaultInstance().getNextPageToken();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* A token, which can be sent as `page_token` to retrieve the next page.
* If this field is omitted, there are no subsequent pages.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The bytes for nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.chronicle.v1.ListRetrohuntsResponse)
}
// @@protoc_insertion_point(class_scope:google.cloud.chronicle.v1.ListRetrohuntsResponse)
private static final com.google.cloud.chronicle.v1.ListRetrohuntsResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.chronicle.v1.ListRetrohuntsResponse();
}
public static com.google.cloud.chronicle.v1.ListRetrohuntsResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListRetrohuntsResponse> PARSER =
new com.google.protobuf.AbstractParser<ListRetrohuntsResponse>() {
@java.lang.Override
public ListRetrohuntsResponse 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<ListRetrohuntsResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListRetrohuntsResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.chronicle.v1.ListRetrohuntsResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,494 | java-discoveryengine/grpc-google-cloud-discoveryengine-v1/src/main/java/com/google/cloud/discoveryengine/v1/SchemaServiceGrpc.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.discoveryengine.v1;
import static io.grpc.MethodDescriptor.generateFullMethodName;
/**
*
*
* <pre>
* Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler",
comments = "Source: google/cloud/discoveryengine/v1/schema_service.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class SchemaServiceGrpc {
private SchemaServiceGrpc() {}
public static final java.lang.String SERVICE_NAME =
"google.cloud.discoveryengine.v1.SchemaService";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.GetSchemaRequest,
com.google.cloud.discoveryengine.v1.Schema>
getGetSchemaMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "GetSchema",
requestType = com.google.cloud.discoveryengine.v1.GetSchemaRequest.class,
responseType = com.google.cloud.discoveryengine.v1.Schema.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.GetSchemaRequest,
com.google.cloud.discoveryengine.v1.Schema>
getGetSchemaMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.GetSchemaRequest,
com.google.cloud.discoveryengine.v1.Schema>
getGetSchemaMethod;
if ((getGetSchemaMethod = SchemaServiceGrpc.getGetSchemaMethod) == null) {
synchronized (SchemaServiceGrpc.class) {
if ((getGetSchemaMethod = SchemaServiceGrpc.getGetSchemaMethod) == null) {
SchemaServiceGrpc.getGetSchemaMethod =
getGetSchemaMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.discoveryengine.v1.GetSchemaRequest,
com.google.cloud.discoveryengine.v1.Schema>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetSchema"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.discoveryengine.v1.GetSchemaRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.discoveryengine.v1.Schema.getDefaultInstance()))
.setSchemaDescriptor(new SchemaServiceMethodDescriptorSupplier("GetSchema"))
.build();
}
}
}
return getGetSchemaMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.ListSchemasRequest,
com.google.cloud.discoveryengine.v1.ListSchemasResponse>
getListSchemasMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "ListSchemas",
requestType = com.google.cloud.discoveryengine.v1.ListSchemasRequest.class,
responseType = com.google.cloud.discoveryengine.v1.ListSchemasResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.ListSchemasRequest,
com.google.cloud.discoveryengine.v1.ListSchemasResponse>
getListSchemasMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.ListSchemasRequest,
com.google.cloud.discoveryengine.v1.ListSchemasResponse>
getListSchemasMethod;
if ((getListSchemasMethod = SchemaServiceGrpc.getListSchemasMethod) == null) {
synchronized (SchemaServiceGrpc.class) {
if ((getListSchemasMethod = SchemaServiceGrpc.getListSchemasMethod) == null) {
SchemaServiceGrpc.getListSchemasMethod =
getListSchemasMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.discoveryengine.v1.ListSchemasRequest,
com.google.cloud.discoveryengine.v1.ListSchemasResponse>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListSchemas"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.discoveryengine.v1.ListSchemasRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.discoveryengine.v1.ListSchemasResponse
.getDefaultInstance()))
.setSchemaDescriptor(new SchemaServiceMethodDescriptorSupplier("ListSchemas"))
.build();
}
}
}
return getListSchemasMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.CreateSchemaRequest, com.google.longrunning.Operation>
getCreateSchemaMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "CreateSchema",
requestType = com.google.cloud.discoveryengine.v1.CreateSchemaRequest.class,
responseType = com.google.longrunning.Operation.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.CreateSchemaRequest, com.google.longrunning.Operation>
getCreateSchemaMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.CreateSchemaRequest,
com.google.longrunning.Operation>
getCreateSchemaMethod;
if ((getCreateSchemaMethod = SchemaServiceGrpc.getCreateSchemaMethod) == null) {
synchronized (SchemaServiceGrpc.class) {
if ((getCreateSchemaMethod = SchemaServiceGrpc.getCreateSchemaMethod) == null) {
SchemaServiceGrpc.getCreateSchemaMethod =
getCreateSchemaMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.discoveryengine.v1.CreateSchemaRequest,
com.google.longrunning.Operation>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateSchema"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.discoveryengine.v1.CreateSchemaRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.longrunning.Operation.getDefaultInstance()))
.setSchemaDescriptor(
new SchemaServiceMethodDescriptorSupplier("CreateSchema"))
.build();
}
}
}
return getCreateSchemaMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest, com.google.longrunning.Operation>
getUpdateSchemaMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "UpdateSchema",
requestType = com.google.cloud.discoveryengine.v1.UpdateSchemaRequest.class,
responseType = com.google.longrunning.Operation.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest, com.google.longrunning.Operation>
getUpdateSchemaMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest,
com.google.longrunning.Operation>
getUpdateSchemaMethod;
if ((getUpdateSchemaMethod = SchemaServiceGrpc.getUpdateSchemaMethod) == null) {
synchronized (SchemaServiceGrpc.class) {
if ((getUpdateSchemaMethod = SchemaServiceGrpc.getUpdateSchemaMethod) == null) {
SchemaServiceGrpc.getUpdateSchemaMethod =
getUpdateSchemaMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.discoveryengine.v1.UpdateSchemaRequest,
com.google.longrunning.Operation>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdateSchema"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.longrunning.Operation.getDefaultInstance()))
.setSchemaDescriptor(
new SchemaServiceMethodDescriptorSupplier("UpdateSchema"))
.build();
}
}
}
return getUpdateSchemaMethod;
}
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest, com.google.longrunning.Operation>
getDeleteSchemaMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "DeleteSchema",
requestType = com.google.cloud.discoveryengine.v1.DeleteSchemaRequest.class,
responseType = com.google.longrunning.Operation.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest, com.google.longrunning.Operation>
getDeleteSchemaMethod() {
io.grpc.MethodDescriptor<
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest,
com.google.longrunning.Operation>
getDeleteSchemaMethod;
if ((getDeleteSchemaMethod = SchemaServiceGrpc.getDeleteSchemaMethod) == null) {
synchronized (SchemaServiceGrpc.class) {
if ((getDeleteSchemaMethod = SchemaServiceGrpc.getDeleteSchemaMethod) == null) {
SchemaServiceGrpc.getDeleteSchemaMethod =
getDeleteSchemaMethod =
io.grpc.MethodDescriptor
.<com.google.cloud.discoveryengine.v1.DeleteSchemaRequest,
com.google.longrunning.Operation>
newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteSchema"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest
.getDefaultInstance()))
.setResponseMarshaller(
io.grpc.protobuf.ProtoUtils.marshaller(
com.google.longrunning.Operation.getDefaultInstance()))
.setSchemaDescriptor(
new SchemaServiceMethodDescriptorSupplier("DeleteSchema"))
.build();
}
}
}
return getDeleteSchemaMethod;
}
/** Creates a new async stub that supports all call types for the service */
public static SchemaServiceStub newStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SchemaServiceStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SchemaServiceStub>() {
@java.lang.Override
public SchemaServiceStub newStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceStub(channel, callOptions);
}
};
return SchemaServiceStub.newStub(factory, channel);
}
/** Creates a new blocking-style stub that supports all types of calls on the service */
public static SchemaServiceBlockingV2Stub newBlockingV2Stub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SchemaServiceBlockingV2Stub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SchemaServiceBlockingV2Stub>() {
@java.lang.Override
public SchemaServiceBlockingV2Stub newStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceBlockingV2Stub(channel, callOptions);
}
};
return SchemaServiceBlockingV2Stub.newStub(factory, channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static SchemaServiceBlockingStub newBlockingStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SchemaServiceBlockingStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SchemaServiceBlockingStub>() {
@java.lang.Override
public SchemaServiceBlockingStub newStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceBlockingStub(channel, callOptions);
}
};
return SchemaServiceBlockingStub.newStub(factory, channel);
}
/** Creates a new ListenableFuture-style stub that supports unary calls on the service */
public static SchemaServiceFutureStub newFutureStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<SchemaServiceFutureStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<SchemaServiceFutureStub>() {
@java.lang.Override
public SchemaServiceFutureStub newStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceFutureStub(channel, callOptions);
}
};
return SchemaServiceFutureStub.newStub(factory, channel);
}
/**
*
*
* <pre>
* Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public interface AsyncService {
/**
*
*
* <pre>
* Gets a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
default void getSchema(
com.google.cloud.discoveryengine.v1.GetSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.discoveryengine.v1.Schema> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetSchemaMethod(), responseObserver);
}
/**
*
*
* <pre>
* Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
default void listSchemas(
com.google.cloud.discoveryengine.v1.ListSchemasRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.discoveryengine.v1.ListSchemasResponse>
responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getListSchemasMethod(), responseObserver);
}
/**
*
*
* <pre>
* Creates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
default void createSchema(
com.google.cloud.discoveryengine.v1.CreateSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getCreateSchemaMethod(), responseObserver);
}
/**
*
*
* <pre>
* Updates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
default void updateSchema(
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getUpdateSchemaMethod(), responseObserver);
}
/**
*
*
* <pre>
* Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
default void deleteSchema(
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
getDeleteSchemaMethod(), responseObserver);
}
}
/**
* Base class for the server implementation of the service SchemaService.
*
* <pre>
* Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public abstract static class SchemaServiceImplBase
implements io.grpc.BindableService, AsyncService {
@java.lang.Override
public final io.grpc.ServerServiceDefinition bindService() {
return SchemaServiceGrpc.bindService(this);
}
}
/**
* A stub to allow clients to do asynchronous rpc calls to service SchemaService.
*
* <pre>
* Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public static final class SchemaServiceStub
extends io.grpc.stub.AbstractAsyncStub<SchemaServiceStub> {
private SchemaServiceStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SchemaServiceStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceStub(channel, callOptions);
}
/**
*
*
* <pre>
* Gets a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public void getSchema(
com.google.cloud.discoveryengine.v1.GetSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.discoveryengine.v1.Schema> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getGetSchemaMethod(), getCallOptions()), request, responseObserver);
}
/**
*
*
* <pre>
* Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public void listSchemas(
com.google.cloud.discoveryengine.v1.ListSchemasRequest request,
io.grpc.stub.StreamObserver<com.google.cloud.discoveryengine.v1.ListSchemasResponse>
responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getListSchemasMethod(), getCallOptions()),
request,
responseObserver);
}
/**
*
*
* <pre>
* Creates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public void createSchema(
com.google.cloud.discoveryengine.v1.CreateSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getCreateSchemaMethod(), getCallOptions()),
request,
responseObserver);
}
/**
*
*
* <pre>
* Updates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public void updateSchema(
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getUpdateSchemaMethod(), getCallOptions()),
request,
responseObserver);
}
/**
*
*
* <pre>
* Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public void deleteSchema(
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getDeleteSchemaMethod(), getCallOptions()),
request,
responseObserver);
}
}
/**
* A stub to allow clients to do synchronous rpc calls to service SchemaService.
*
* <pre>
* Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public static final class SchemaServiceBlockingV2Stub
extends io.grpc.stub.AbstractBlockingStub<SchemaServiceBlockingV2Stub> {
private SchemaServiceBlockingV2Stub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SchemaServiceBlockingV2Stub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceBlockingV2Stub(channel, callOptions);
}
/**
*
*
* <pre>
* Gets a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.cloud.discoveryengine.v1.Schema getSchema(
com.google.cloud.discoveryengine.v1.GetSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getGetSchemaMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public com.google.cloud.discoveryengine.v1.ListSchemasResponse listSchemas(
com.google.cloud.discoveryengine.v1.ListSchemasRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getListSchemasMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Creates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.longrunning.Operation createSchema(
com.google.cloud.discoveryengine.v1.CreateSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getCreateSchemaMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Updates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.longrunning.Operation updateSchema(
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getUpdateSchemaMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.longrunning.Operation deleteSchema(
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getDeleteSchemaMethod(), getCallOptions(), request);
}
}
/**
* A stub to allow clients to do limited synchronous rpc calls to service SchemaService.
*
* <pre>
* Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public static final class SchemaServiceBlockingStub
extends io.grpc.stub.AbstractBlockingStub<SchemaServiceBlockingStub> {
private SchemaServiceBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SchemaServiceBlockingStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceBlockingStub(channel, callOptions);
}
/**
*
*
* <pre>
* Gets a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.cloud.discoveryengine.v1.Schema getSchema(
com.google.cloud.discoveryengine.v1.GetSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getGetSchemaMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public com.google.cloud.discoveryengine.v1.ListSchemasResponse listSchemas(
com.google.cloud.discoveryengine.v1.ListSchemasRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getListSchemasMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Creates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.longrunning.Operation createSchema(
com.google.cloud.discoveryengine.v1.CreateSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getCreateSchemaMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Updates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.longrunning.Operation updateSchema(
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getUpdateSchemaMethod(), getCallOptions(), request);
}
/**
*
*
* <pre>
* Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.longrunning.Operation deleteSchema(
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getDeleteSchemaMethod(), getCallOptions(), request);
}
}
/**
* A stub to allow clients to do ListenableFuture-style rpc calls to service SchemaService.
*
* <pre>
* Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public static final class SchemaServiceFutureStub
extends io.grpc.stub.AbstractFutureStub<SchemaServiceFutureStub> {
private SchemaServiceFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected SchemaServiceFutureStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new SchemaServiceFutureStub(channel, callOptions);
}
/**
*
*
* <pre>
* Gets a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<
com.google.cloud.discoveryengine.v1.Schema>
getSchema(com.google.cloud.discoveryengine.v1.GetSchemaRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getGetSchemaMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<
com.google.cloud.discoveryengine.v1.ListSchemasResponse>
listSchemas(com.google.cloud.discoveryengine.v1.ListSchemasRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getListSchemasMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Creates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.longrunning.Operation>
createSchema(com.google.cloud.discoveryengine.v1.CreateSchemaRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getCreateSchemaMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Updates a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.longrunning.Operation>
updateSchema(com.google.cloud.discoveryengine.v1.UpdateSchemaRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getUpdateSchemaMethod(), getCallOptions()), request);
}
/**
*
*
* <pre>
* Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.longrunning.Operation>
deleteSchema(com.google.cloud.discoveryengine.v1.DeleteSchemaRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getDeleteSchemaMethod(), getCallOptions()), request);
}
}
private static final int METHODID_GET_SCHEMA = 0;
private static final int METHODID_LIST_SCHEMAS = 1;
private static final int METHODID_CREATE_SCHEMA = 2;
private static final int METHODID_UPDATE_SCHEMA = 3;
private static final int METHODID_DELETE_SCHEMA = 4;
private static final class MethodHandlers<Req, Resp>
implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final AsyncService serviceImpl;
private final int methodId;
MethodHandlers(AsyncService serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_GET_SCHEMA:
serviceImpl.getSchema(
(com.google.cloud.discoveryengine.v1.GetSchemaRequest) request,
(io.grpc.stub.StreamObserver<com.google.cloud.discoveryengine.v1.Schema>)
responseObserver);
break;
case METHODID_LIST_SCHEMAS:
serviceImpl.listSchemas(
(com.google.cloud.discoveryengine.v1.ListSchemasRequest) request,
(io.grpc.stub.StreamObserver<com.google.cloud.discoveryengine.v1.ListSchemasResponse>)
responseObserver);
break;
case METHODID_CREATE_SCHEMA:
serviceImpl.createSchema(
(com.google.cloud.discoveryengine.v1.CreateSchemaRequest) request,
(io.grpc.stub.StreamObserver<com.google.longrunning.Operation>) responseObserver);
break;
case METHODID_UPDATE_SCHEMA:
serviceImpl.updateSchema(
(com.google.cloud.discoveryengine.v1.UpdateSchemaRequest) request,
(io.grpc.stub.StreamObserver<com.google.longrunning.Operation>) responseObserver);
break;
case METHODID_DELETE_SCHEMA:
serviceImpl.deleteSchema(
(com.google.cloud.discoveryengine.v1.DeleteSchemaRequest) request,
(io.grpc.stub.StreamObserver<com.google.longrunning.Operation>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
}
public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getGetSchemaMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.discoveryengine.v1.GetSchemaRequest,
com.google.cloud.discoveryengine.v1.Schema>(service, METHODID_GET_SCHEMA)))
.addMethod(
getListSchemasMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.discoveryengine.v1.ListSchemasRequest,
com.google.cloud.discoveryengine.v1.ListSchemasResponse>(
service, METHODID_LIST_SCHEMAS)))
.addMethod(
getCreateSchemaMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.discoveryengine.v1.CreateSchemaRequest,
com.google.longrunning.Operation>(service, METHODID_CREATE_SCHEMA)))
.addMethod(
getUpdateSchemaMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.discoveryengine.v1.UpdateSchemaRequest,
com.google.longrunning.Operation>(service, METHODID_UPDATE_SCHEMA)))
.addMethod(
getDeleteSchemaMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.cloud.discoveryengine.v1.DeleteSchemaRequest,
com.google.longrunning.Operation>(service, METHODID_DELETE_SCHEMA)))
.build();
}
private abstract static class SchemaServiceBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier,
io.grpc.protobuf.ProtoServiceDescriptorSupplier {
SchemaServiceBaseDescriptorSupplier() {}
@java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return com.google.cloud.discoveryengine.v1.SchemaServiceProto.getDescriptor();
}
@java.lang.Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("SchemaService");
}
}
private static final class SchemaServiceFileDescriptorSupplier
extends SchemaServiceBaseDescriptorSupplier {
SchemaServiceFileDescriptorSupplier() {}
}
private static final class SchemaServiceMethodDescriptorSupplier
extends SchemaServiceBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final java.lang.String methodName;
SchemaServiceMethodDescriptorSupplier(java.lang.String methodName) {
this.methodName = methodName;
}
@java.lang.Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (SchemaServiceGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor =
result =
io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new SchemaServiceFileDescriptorSupplier())
.addMethod(getGetSchemaMethod())
.addMethod(getListSchemasMethod())
.addMethod(getCreateSchemaMethod())
.addMethod(getUpdateSchemaMethod())
.addMethod(getDeleteSchemaMethod())
.build();
}
}
}
return result;
}
}
|
googleapis/google-cloud-java | 36,423 | java-aiplatform/proto-google-cloud-aiplatform-v1beta1/src/main/java/com/google/cloud/aiplatform/v1beta1/ToolCallValidResults.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/aiplatform/v1beta1/evaluation_service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.aiplatform.v1beta1;
/**
*
*
* <pre>
* Results for tool call valid metric.
* </pre>
*
* Protobuf type {@code google.cloud.aiplatform.v1beta1.ToolCallValidResults}
*/
public final class ToolCallValidResults extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.aiplatform.v1beta1.ToolCallValidResults)
ToolCallValidResultsOrBuilder {
private static final long serialVersionUID = 0L;
// Use ToolCallValidResults.newBuilder() to construct.
private ToolCallValidResults(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ToolCallValidResults() {
toolCallValidMetricValues_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ToolCallValidResults();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolCallValidResults_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolCallValidResults_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults.class,
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults.Builder.class);
}
public static final int TOOL_CALL_VALID_METRIC_VALUES_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue>
toolCallValidMetricValues_;
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue>
getToolCallValidMetricValuesList() {
return toolCallValidMetricValues_;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public java.util.List<
? extends com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValueOrBuilder>
getToolCallValidMetricValuesOrBuilderList() {
return toolCallValidMetricValues_;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public int getToolCallValidMetricValuesCount() {
return toolCallValidMetricValues_.size();
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue getToolCallValidMetricValues(
int index) {
return toolCallValidMetricValues_.get(index);
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValueOrBuilder
getToolCallValidMetricValuesOrBuilder(int index) {
return toolCallValidMetricValues_.get(index);
}
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 {
for (int i = 0; i < toolCallValidMetricValues_.size(); i++) {
output.writeMessage(1, toolCallValidMetricValues_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < toolCallValidMetricValues_.size(); i++) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
1, toolCallValidMetricValues_.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.aiplatform.v1beta1.ToolCallValidResults)) {
return super.equals(obj);
}
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults other =
(com.google.cloud.aiplatform.v1beta1.ToolCallValidResults) obj;
if (!getToolCallValidMetricValuesList().equals(other.getToolCallValidMetricValuesList()))
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 (getToolCallValidMetricValuesCount() > 0) {
hash = (37 * hash) + TOOL_CALL_VALID_METRIC_VALUES_FIELD_NUMBER;
hash = (53 * hash) + getToolCallValidMetricValuesList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults 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.aiplatform.v1beta1.ToolCallValidResults parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults 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.aiplatform.v1beta1.ToolCallValidResults parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults 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.aiplatform.v1beta1.ToolCallValidResults parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults 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.aiplatform.v1beta1.ToolCallValidResults parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults 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.aiplatform.v1beta1.ToolCallValidResults 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;
}
/**
*
*
* <pre>
* Results for tool call valid metric.
* </pre>
*
* Protobuf type {@code google.cloud.aiplatform.v1beta1.ToolCallValidResults}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.aiplatform.v1beta1.ToolCallValidResults)
com.google.cloud.aiplatform.v1beta1.ToolCallValidResultsOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolCallValidResults_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolCallValidResults_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults.class,
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults.Builder.class);
}
// Construct using com.google.cloud.aiplatform.v1beta1.ToolCallValidResults.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (toolCallValidMetricValuesBuilder_ == null) {
toolCallValidMetricValues_ = java.util.Collections.emptyList();
} else {
toolCallValidMetricValues_ = null;
toolCallValidMetricValuesBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolCallValidResults_descriptor;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolCallValidResults getDefaultInstanceForType() {
return com.google.cloud.aiplatform.v1beta1.ToolCallValidResults.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolCallValidResults build() {
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolCallValidResults buildPartial() {
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults result =
new com.google.cloud.aiplatform.v1beta1.ToolCallValidResults(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.aiplatform.v1beta1.ToolCallValidResults result) {
if (toolCallValidMetricValuesBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
toolCallValidMetricValues_ =
java.util.Collections.unmodifiableList(toolCallValidMetricValues_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.toolCallValidMetricValues_ = toolCallValidMetricValues_;
} else {
result.toolCallValidMetricValues_ = toolCallValidMetricValuesBuilder_.build();
}
}
private void buildPartial0(com.google.cloud.aiplatform.v1beta1.ToolCallValidResults result) {
int from_bitField0_ = bitField0_;
}
@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.aiplatform.v1beta1.ToolCallValidResults) {
return mergeFrom((com.google.cloud.aiplatform.v1beta1.ToolCallValidResults) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.aiplatform.v1beta1.ToolCallValidResults other) {
if (other == com.google.cloud.aiplatform.v1beta1.ToolCallValidResults.getDefaultInstance())
return this;
if (toolCallValidMetricValuesBuilder_ == null) {
if (!other.toolCallValidMetricValues_.isEmpty()) {
if (toolCallValidMetricValues_.isEmpty()) {
toolCallValidMetricValues_ = other.toolCallValidMetricValues_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.addAll(other.toolCallValidMetricValues_);
}
onChanged();
}
} else {
if (!other.toolCallValidMetricValues_.isEmpty()) {
if (toolCallValidMetricValuesBuilder_.isEmpty()) {
toolCallValidMetricValuesBuilder_.dispose();
toolCallValidMetricValuesBuilder_ = null;
toolCallValidMetricValues_ = other.toolCallValidMetricValues_;
bitField0_ = (bitField0_ & ~0x00000001);
toolCallValidMetricValuesBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getToolCallValidMetricValuesFieldBuilder()
: null;
} else {
toolCallValidMetricValuesBuilder_.addAllMessages(other.toolCallValidMetricValues_);
}
}
}
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 10:
{
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue m =
input.readMessage(
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.parser(),
extensionRegistry);
if (toolCallValidMetricValuesBuilder_ == null) {
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.add(m);
} else {
toolCallValidMetricValuesBuilder_.addMessage(m);
}
break;
} // case 10
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.aiplatform.v1beta1.ToolCallValidMetricValue>
toolCallValidMetricValues_ = java.util.Collections.emptyList();
private void ensureToolCallValidMetricValuesIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
toolCallValidMetricValues_ =
new java.util.ArrayList<com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue>(
toolCallValidMetricValues_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValueOrBuilder>
toolCallValidMetricValuesBuilder_;
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public java.util.List<com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue>
getToolCallValidMetricValuesList() {
if (toolCallValidMetricValuesBuilder_ == null) {
return java.util.Collections.unmodifiableList(toolCallValidMetricValues_);
} else {
return toolCallValidMetricValuesBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public int getToolCallValidMetricValuesCount() {
if (toolCallValidMetricValuesBuilder_ == null) {
return toolCallValidMetricValues_.size();
} else {
return toolCallValidMetricValuesBuilder_.getCount();
}
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue
getToolCallValidMetricValues(int index) {
if (toolCallValidMetricValuesBuilder_ == null) {
return toolCallValidMetricValues_.get(index);
} else {
return toolCallValidMetricValuesBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder setToolCallValidMetricValues(
int index, com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue value) {
if (toolCallValidMetricValuesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.set(index, value);
onChanged();
} else {
toolCallValidMetricValuesBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder setToolCallValidMetricValues(
int index,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder builderForValue) {
if (toolCallValidMetricValuesBuilder_ == null) {
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.set(index, builderForValue.build());
onChanged();
} else {
toolCallValidMetricValuesBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolCallValidMetricValues(
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue value) {
if (toolCallValidMetricValuesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.add(value);
onChanged();
} else {
toolCallValidMetricValuesBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolCallValidMetricValues(
int index, com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue value) {
if (toolCallValidMetricValuesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.add(index, value);
onChanged();
} else {
toolCallValidMetricValuesBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolCallValidMetricValues(
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder builderForValue) {
if (toolCallValidMetricValuesBuilder_ == null) {
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.add(builderForValue.build());
onChanged();
} else {
toolCallValidMetricValuesBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolCallValidMetricValues(
int index,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder builderForValue) {
if (toolCallValidMetricValuesBuilder_ == null) {
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.add(index, builderForValue.build());
onChanged();
} else {
toolCallValidMetricValuesBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addAllToolCallValidMetricValues(
java.lang.Iterable<? extends com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue>
values) {
if (toolCallValidMetricValuesBuilder_ == null) {
ensureToolCallValidMetricValuesIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, toolCallValidMetricValues_);
onChanged();
} else {
toolCallValidMetricValuesBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder clearToolCallValidMetricValues() {
if (toolCallValidMetricValuesBuilder_ == null) {
toolCallValidMetricValues_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
toolCallValidMetricValuesBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder removeToolCallValidMetricValues(int index) {
if (toolCallValidMetricValuesBuilder_ == null) {
ensureToolCallValidMetricValuesIsMutable();
toolCallValidMetricValues_.remove(index);
onChanged();
} else {
toolCallValidMetricValuesBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder
getToolCallValidMetricValuesBuilder(int index) {
return getToolCallValidMetricValuesFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValueOrBuilder
getToolCallValidMetricValuesOrBuilder(int index) {
if (toolCallValidMetricValuesBuilder_ == null) {
return toolCallValidMetricValues_.get(index);
} else {
return toolCallValidMetricValuesBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public java.util.List<
? extends com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValueOrBuilder>
getToolCallValidMetricValuesOrBuilderList() {
if (toolCallValidMetricValuesBuilder_ != null) {
return toolCallValidMetricValuesBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(toolCallValidMetricValues_);
}
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder
addToolCallValidMetricValuesBuilder() {
return getToolCallValidMetricValuesFieldBuilder()
.addBuilder(
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.getDefaultInstance());
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder
addToolCallValidMetricValuesBuilder(int index) {
return getToolCallValidMetricValuesFieldBuilder()
.addBuilder(
index,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.getDefaultInstance());
}
/**
*
*
* <pre>
* Output only. Tool call valid metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue tool_call_valid_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public java.util.List<com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder>
getToolCallValidMetricValuesBuilderList() {
return getToolCallValidMetricValuesFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValueOrBuilder>
getToolCallValidMetricValuesFieldBuilder() {
if (toolCallValidMetricValuesBuilder_ == null) {
toolCallValidMetricValuesBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValue.Builder,
com.google.cloud.aiplatform.v1beta1.ToolCallValidMetricValueOrBuilder>(
toolCallValidMetricValues_,
((bitField0_ & 0x00000001) != 0),
getParentForChildren(),
isClean());
toolCallValidMetricValues_ = null;
}
return toolCallValidMetricValuesBuilder_;
}
@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.aiplatform.v1beta1.ToolCallValidResults)
}
// @@protoc_insertion_point(class_scope:google.cloud.aiplatform.v1beta1.ToolCallValidResults)
private static final com.google.cloud.aiplatform.v1beta1.ToolCallValidResults DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.aiplatform.v1beta1.ToolCallValidResults();
}
public static com.google.cloud.aiplatform.v1beta1.ToolCallValidResults getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ToolCallValidResults> PARSER =
new com.google.protobuf.AbstractParser<ToolCallValidResults>() {
@java.lang.Override
public ToolCallValidResults 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<ToolCallValidResults> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ToolCallValidResults> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolCallValidResults getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,423 | java-aiplatform/proto-google-cloud-aiplatform-v1beta1/src/main/java/com/google/cloud/aiplatform/v1beta1/ToolNameMatchResults.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/aiplatform/v1beta1/evaluation_service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.aiplatform.v1beta1;
/**
*
*
* <pre>
* Results for tool name match metric.
* </pre>
*
* Protobuf type {@code google.cloud.aiplatform.v1beta1.ToolNameMatchResults}
*/
public final class ToolNameMatchResults extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.aiplatform.v1beta1.ToolNameMatchResults)
ToolNameMatchResultsOrBuilder {
private static final long serialVersionUID = 0L;
// Use ToolNameMatchResults.newBuilder() to construct.
private ToolNameMatchResults(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ToolNameMatchResults() {
toolNameMatchMetricValues_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ToolNameMatchResults();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolNameMatchResults_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolNameMatchResults_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults.class,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults.Builder.class);
}
public static final int TOOL_NAME_MATCH_METRIC_VALUES_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue>
toolNameMatchMetricValues_;
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public java.util.List<com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue>
getToolNameMatchMetricValuesList() {
return toolNameMatchMetricValues_;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public java.util.List<
? extends com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValueOrBuilder>
getToolNameMatchMetricValuesOrBuilderList() {
return toolNameMatchMetricValues_;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public int getToolNameMatchMetricValuesCount() {
return toolNameMatchMetricValues_.size();
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue getToolNameMatchMetricValues(
int index) {
return toolNameMatchMetricValues_.get(index);
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValueOrBuilder
getToolNameMatchMetricValuesOrBuilder(int index) {
return toolNameMatchMetricValues_.get(index);
}
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 {
for (int i = 0; i < toolNameMatchMetricValues_.size(); i++) {
output.writeMessage(1, toolNameMatchMetricValues_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < toolNameMatchMetricValues_.size(); i++) {
size +=
com.google.protobuf.CodedOutputStream.computeMessageSize(
1, toolNameMatchMetricValues_.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.aiplatform.v1beta1.ToolNameMatchResults)) {
return super.equals(obj);
}
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults other =
(com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults) obj;
if (!getToolNameMatchMetricValuesList().equals(other.getToolNameMatchMetricValuesList()))
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 (getToolNameMatchMetricValuesCount() > 0) {
hash = (37 * hash) + TOOL_NAME_MATCH_METRIC_VALUES_FIELD_NUMBER;
hash = (53 * hash) + getToolNameMatchMetricValuesList().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults 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.aiplatform.v1beta1.ToolNameMatchResults parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults 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.aiplatform.v1beta1.ToolNameMatchResults parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults 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.aiplatform.v1beta1.ToolNameMatchResults parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults 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.aiplatform.v1beta1.ToolNameMatchResults parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults 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.aiplatform.v1beta1.ToolNameMatchResults 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;
}
/**
*
*
* <pre>
* Results for tool name match metric.
* </pre>
*
* Protobuf type {@code google.cloud.aiplatform.v1beta1.ToolNameMatchResults}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.aiplatform.v1beta1.ToolNameMatchResults)
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResultsOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolNameMatchResults_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolNameMatchResults_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults.class,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults.Builder.class);
}
// Construct using com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (toolNameMatchMetricValuesBuilder_ == null) {
toolNameMatchMetricValues_ = java.util.Collections.emptyList();
} else {
toolNameMatchMetricValues_ = null;
toolNameMatchMetricValuesBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.aiplatform.v1beta1.EvaluationServiceProto
.internal_static_google_cloud_aiplatform_v1beta1_ToolNameMatchResults_descriptor;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults getDefaultInstanceForType() {
return com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults build() {
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults buildPartial() {
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults result =
new com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults result) {
if (toolNameMatchMetricValuesBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
toolNameMatchMetricValues_ =
java.util.Collections.unmodifiableList(toolNameMatchMetricValues_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.toolNameMatchMetricValues_ = toolNameMatchMetricValues_;
} else {
result.toolNameMatchMetricValues_ = toolNameMatchMetricValuesBuilder_.build();
}
}
private void buildPartial0(com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults result) {
int from_bitField0_ = bitField0_;
}
@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.aiplatform.v1beta1.ToolNameMatchResults) {
return mergeFrom((com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults other) {
if (other == com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults.getDefaultInstance())
return this;
if (toolNameMatchMetricValuesBuilder_ == null) {
if (!other.toolNameMatchMetricValues_.isEmpty()) {
if (toolNameMatchMetricValues_.isEmpty()) {
toolNameMatchMetricValues_ = other.toolNameMatchMetricValues_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.addAll(other.toolNameMatchMetricValues_);
}
onChanged();
}
} else {
if (!other.toolNameMatchMetricValues_.isEmpty()) {
if (toolNameMatchMetricValuesBuilder_.isEmpty()) {
toolNameMatchMetricValuesBuilder_.dispose();
toolNameMatchMetricValuesBuilder_ = null;
toolNameMatchMetricValues_ = other.toolNameMatchMetricValues_;
bitField0_ = (bitField0_ & ~0x00000001);
toolNameMatchMetricValuesBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getToolNameMatchMetricValuesFieldBuilder()
: null;
} else {
toolNameMatchMetricValuesBuilder_.addAllMessages(other.toolNameMatchMetricValues_);
}
}
}
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 10:
{
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue m =
input.readMessage(
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.parser(),
extensionRegistry);
if (toolNameMatchMetricValuesBuilder_ == null) {
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.add(m);
} else {
toolNameMatchMetricValuesBuilder_.addMessage(m);
}
break;
} // case 10
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.aiplatform.v1beta1.ToolNameMatchMetricValue>
toolNameMatchMetricValues_ = java.util.Collections.emptyList();
private void ensureToolNameMatchMetricValuesIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
toolNameMatchMetricValues_ =
new java.util.ArrayList<com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue>(
toolNameMatchMetricValues_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValueOrBuilder>
toolNameMatchMetricValuesBuilder_;
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public java.util.List<com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue>
getToolNameMatchMetricValuesList() {
if (toolNameMatchMetricValuesBuilder_ == null) {
return java.util.Collections.unmodifiableList(toolNameMatchMetricValues_);
} else {
return toolNameMatchMetricValuesBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public int getToolNameMatchMetricValuesCount() {
if (toolNameMatchMetricValuesBuilder_ == null) {
return toolNameMatchMetricValues_.size();
} else {
return toolNameMatchMetricValuesBuilder_.getCount();
}
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue
getToolNameMatchMetricValues(int index) {
if (toolNameMatchMetricValuesBuilder_ == null) {
return toolNameMatchMetricValues_.get(index);
} else {
return toolNameMatchMetricValuesBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder setToolNameMatchMetricValues(
int index, com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue value) {
if (toolNameMatchMetricValuesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.set(index, value);
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder setToolNameMatchMetricValues(
int index,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder builderForValue) {
if (toolNameMatchMetricValuesBuilder_ == null) {
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.set(index, builderForValue.build());
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolNameMatchMetricValues(
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue value) {
if (toolNameMatchMetricValuesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.add(value);
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolNameMatchMetricValues(
int index, com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue value) {
if (toolNameMatchMetricValuesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.add(index, value);
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolNameMatchMetricValues(
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder builderForValue) {
if (toolNameMatchMetricValuesBuilder_ == null) {
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.add(builderForValue.build());
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addToolNameMatchMetricValues(
int index,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder builderForValue) {
if (toolNameMatchMetricValuesBuilder_ == null) {
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.add(index, builderForValue.build());
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder addAllToolNameMatchMetricValues(
java.lang.Iterable<? extends com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue>
values) {
if (toolNameMatchMetricValuesBuilder_ == null) {
ensureToolNameMatchMetricValuesIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, toolNameMatchMetricValues_);
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder clearToolNameMatchMetricValues() {
if (toolNameMatchMetricValuesBuilder_ == null) {
toolNameMatchMetricValues_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public Builder removeToolNameMatchMetricValues(int index) {
if (toolNameMatchMetricValuesBuilder_ == null) {
ensureToolNameMatchMetricValuesIsMutable();
toolNameMatchMetricValues_.remove(index);
onChanged();
} else {
toolNameMatchMetricValuesBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder
getToolNameMatchMetricValuesBuilder(int index) {
return getToolNameMatchMetricValuesFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValueOrBuilder
getToolNameMatchMetricValuesOrBuilder(int index) {
if (toolNameMatchMetricValuesBuilder_ == null) {
return toolNameMatchMetricValues_.get(index);
} else {
return toolNameMatchMetricValuesBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public java.util.List<
? extends com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValueOrBuilder>
getToolNameMatchMetricValuesOrBuilderList() {
if (toolNameMatchMetricValuesBuilder_ != null) {
return toolNameMatchMetricValuesBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(toolNameMatchMetricValues_);
}
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder
addToolNameMatchMetricValuesBuilder() {
return getToolNameMatchMetricValuesFieldBuilder()
.addBuilder(
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.getDefaultInstance());
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder
addToolNameMatchMetricValuesBuilder(int index) {
return getToolNameMatchMetricValuesFieldBuilder()
.addBuilder(
index,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.getDefaultInstance());
}
/**
*
*
* <pre>
* Output only. Tool name match metric values.
* </pre>
*
* <code>
* repeated .google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue tool_name_match_metric_values = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
* </code>
*/
public java.util.List<com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder>
getToolNameMatchMetricValuesBuilderList() {
return getToolNameMatchMetricValuesFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValueOrBuilder>
getToolNameMatchMetricValuesFieldBuilder() {
if (toolNameMatchMetricValuesBuilder_ == null) {
toolNameMatchMetricValuesBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValue.Builder,
com.google.cloud.aiplatform.v1beta1.ToolNameMatchMetricValueOrBuilder>(
toolNameMatchMetricValues_,
((bitField0_ & 0x00000001) != 0),
getParentForChildren(),
isClean());
toolNameMatchMetricValues_ = null;
}
return toolNameMatchMetricValuesBuilder_;
}
@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.aiplatform.v1beta1.ToolNameMatchResults)
}
// @@protoc_insertion_point(class_scope:google.cloud.aiplatform.v1beta1.ToolNameMatchResults)
private static final com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults();
}
public static com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ToolNameMatchResults> PARSER =
new com.google.protobuf.AbstractParser<ToolNameMatchResults>() {
@java.lang.Override
public ToolNameMatchResults 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<ToolNameMatchResults> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ToolNameMatchResults> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1beta1.ToolNameMatchResults getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/linkis | 35,822 | linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.linkis.manager.am.restful;
import org.apache.linkis.common.ServiceInstance;
import org.apache.linkis.common.conf.Configuration;
import org.apache.linkis.common.exception.LinkisRetryException;
import org.apache.linkis.common.utils.ByteTimeUtils;
import org.apache.linkis.common.utils.JsonUtils;
import org.apache.linkis.governance.common.conf.GovernanceCommonConf;
import org.apache.linkis.governance.common.constant.ec.ECConstants;
import org.apache.linkis.governance.common.utils.JobUtils;
import org.apache.linkis.governance.common.utils.LoggerUtils;
import org.apache.linkis.manager.am.conf.AMConfiguration;
import org.apache.linkis.manager.am.exception.AMErrorCode;
import org.apache.linkis.manager.am.exception.AMErrorException;
import org.apache.linkis.manager.am.manager.EngineNodeManager;
import org.apache.linkis.manager.am.service.ECResourceInfoService;
import org.apache.linkis.manager.am.service.engine.*;
import org.apache.linkis.manager.am.util.ECResourceInfoUtils;
import org.apache.linkis.manager.am.utils.AMUtils;
import org.apache.linkis.manager.am.vo.AMEngineNodeVo;
import org.apache.linkis.manager.common.constant.AMConstant;
import org.apache.linkis.manager.common.entity.enumeration.NodeHealthy;
import org.apache.linkis.manager.common.entity.enumeration.NodeStatus;
import org.apache.linkis.manager.common.entity.node.AMEMNode;
import org.apache.linkis.manager.common.entity.node.EMNode;
import org.apache.linkis.manager.common.entity.node.EngineNode;
import org.apache.linkis.manager.common.entity.persistence.ECResourceInfoRecord;
import org.apache.linkis.manager.common.protocol.engine.*;
import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactory;
import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext;
import org.apache.linkis.manager.label.constant.LabelKeyConstant;
import org.apache.linkis.manager.label.entity.Label;
import org.apache.linkis.manager.label.entity.UserModifiable;
import org.apache.linkis.manager.label.exception.LabelErrorException;
import org.apache.linkis.manager.label.service.NodeLabelService;
import org.apache.linkis.rpc.Sender;
import org.apache.linkis.server.Message;
import org.apache.linkis.server.utils.ModuleUserUtils;
import org.apache.linkis.storage.utils.StorageUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Api(tags = "EC(engineconn) operation")
@RequestMapping(
path = "/linkisManager",
produces = {"application/json"})
@RestController
public class EngineRestfulApi {
@Autowired private EngineInfoService engineInfoService;
@Autowired private EngineAskEngineService engineAskService;
@Autowired private EngineCreateService engineCreateService;
@Autowired private EngineNodeManager engineNodeManager;
@Autowired private EngineOperateService engineOperateService;
@Autowired private NodeLabelService nodeLabelService;
@Autowired private EngineStopService engineStopService;
@Autowired private ECResourceInfoService ecResourceInfoService;
@Autowired private EngineReuseService engineReuseService;
private final ObjectMapper objectMapper = new ObjectMapper();
private LabelBuilderFactory stdLabelBuilderFactory =
LabelBuilderFactoryContext.getLabelBuilderFactory();
private static final Logger logger = LoggerFactory.getLogger(EngineRestfulApi.class);
@ApiOperation(value = "askEngineConn", response = Message.class)
@ApiOperationSupport(ignoreParameters = {"jsonNode"})
@RequestMapping(path = "/askEngineConn", method = RequestMethod.POST)
public Message askEngineConn(
HttpServletRequest req, @RequestBody EngineAskRequest engineAskRequest)
throws IOException, InterruptedException {
String userName = ModuleUserUtils.getOperationUser(req, "askEngineConn");
engineAskRequest.setUser(userName);
long timeout = engineAskRequest.getTimeOut();
if (timeout <= 0) {
timeout = AMConfiguration.ENGINE_CONN_START_REST_MAX_WAIT_TIME.getValue().toLong();
engineAskRequest.setTimeOut(timeout);
}
Map<String, Object> retEngineNode = new HashMap<>();
logger.info(
"User {} try to ask an engineConn with maxStartTime {}. EngineAskRequest is {}.",
userName,
ByteTimeUtils.msDurationToString(timeout),
engineAskRequest);
Sender sender = Sender.getSender(Sender.getThisServiceInstance());
EngineNode engineNode = null;
// try to reuse ec first
String taskId = JobUtils.getJobIdFromStringMap(engineAskRequest.getProperties());
LoggerUtils.setJobIdMDC(taskId);
logger.info("received task : {}, engineAskRequest : {}", taskId, engineAskRequest);
if (!engineAskRequest.getLabels().containsKey(LabelKeyConstant.EXECUTE_ONCE_KEY)) {
EngineReuseRequest engineReuseRequest = new EngineReuseRequest();
engineReuseRequest.setLabels(engineAskRequest.getLabels());
engineReuseRequest.setTimeOut(engineAskRequest.getTimeOut());
engineReuseRequest.setUser(engineAskRequest.getUser());
engineReuseRequest.setProperties(engineAskRequest.getProperties());
boolean end = false;
EngineNode reuseNode = null;
int count = 0;
int MAX_RETRY = 2;
while (!end) {
try {
reuseNode = engineReuseService.reuseEngine(engineReuseRequest, sender);
end = true;
} catch (LinkisRetryException e) {
logger.error(
"task: {}, user: {} reuse engine failed", taskId, engineReuseRequest.getUser(), e);
Thread.sleep(1000);
end = false;
count += 1;
if (count > MAX_RETRY) {
end = true;
}
} catch (Exception e1) {
logger.info(
"task: {} user: {} reuse engine failed", taskId, engineReuseRequest.getUser(), e1);
end = true;
}
}
if (null != reuseNode) {
logger.info(
"Finished to ask engine for task: {}, user: {} by reuse node {}",
taskId,
engineReuseRequest.getUser(),
reuseNode);
LoggerUtils.removeJobIdMDC();
engineNode = reuseNode;
}
}
if (null != engineNode) {
fillResultEngineNode(retEngineNode, engineNode);
return Message.ok("reuse engineConn ended.").data("engine", retEngineNode);
}
String engineAskAsyncId = EngineAskEngineService$.MODULE$.getAsyncId();
Callable<Object> createECTask =
new Callable() {
@Override
public Object call() {
LoggerUtils.setJobIdMDC(taskId);
logger.info(
"Task: {}, start to async({}) createEngine: {}",
taskId,
engineAskAsyncId,
engineAskRequest.getCreateService());
// remove engineInstance label if exists
engineAskRequest.getLabels().remove("engineInstance");
EngineCreateRequest engineCreateRequest = new EngineCreateRequest();
engineCreateRequest.setLabels(engineAskRequest.getLabels());
engineCreateRequest.setTimeout(engineAskRequest.getTimeOut());
engineCreateRequest.setUser(engineAskRequest.getUser());
engineCreateRequest.setProperties(engineAskRequest.getProperties());
engineCreateRequest.setCreateService(engineAskRequest.getCreateService());
try {
EngineNode createNode = engineCreateService.createEngine(engineCreateRequest, sender);
long timeout = 0L;
if (engineCreateRequest.getTimeout() <= 0) {
timeout = AMConfiguration.ENGINE_START_MAX_TIME.getValue().toLong();
} else {
timeout = engineCreateRequest.getTimeout();
}
// useEngine need to add timeout
EngineNode createEngineNode = engineNodeManager.useEngine(createNode, timeout);
if (null == createEngineNode) {
throw new LinkisRetryException(
AMConstant.EM_ERROR_CODE,
"create engine${createNode.getServiceInstance} success, but to use engine failed");
}
logger.info(
"Task: $taskId finished to ask engine for user ${engineAskRequest.getUser} by create node $createEngineNode");
return createEngineNode;
} catch (Exception e) {
logger.error(
"Task: {} failed to ask engine for user {} by create node", taskId, userName, e);
return new LinkisRetryException(AMConstant.EM_ERROR_CODE, e.getMessage());
} finally {
LoggerUtils.removeJobIdMDC();
}
}
};
try {
Object rs = createECTask.call();
if (rs instanceof LinkisRetryException) {
throw (LinkisRetryException) rs;
} else {
engineNode = (EngineNode) rs;
}
} catch (LinkisRetryException retryException) {
logger.error(
"User {} create engineConn failed get retry exception. can be Retry",
userName,
retryException);
return Message.error(
String.format(
"Create engineConn failed, caused by %s.",
ExceptionUtils.getRootCauseMessage(retryException)))
.data("canRetry", true);
} catch (Exception e) {
LoggerUtils.removeJobIdMDC();
logger.error("User {} create engineConn failed get retry exception", userName, e);
return Message.error(
String.format(
"Create engineConn failed, caused by %s.", ExceptionUtils.getRootCauseMessage(e)));
}
LoggerUtils.removeJobIdMDC();
fillResultEngineNode(retEngineNode, engineNode);
logger.info(
"Finished to create a engineConn for user {}. NodeInfo is {}.", userName, engineNode);
// to transform to a map
return Message.ok("create engineConn ended.").data("engine", retEngineNode);
}
private void fillNullNode(
Map<String, Object> retEngineNode, EngineAskAsyncResponse askAsyncResponse) {
retEngineNode.put(AMConstant.EC_ASYNC_START_RESULT_KEY, AMConstant.EC_ASYNC_START_RESULT_FAIL);
retEngineNode.put(
AMConstant.EC_ASYNC_START_FAIL_MSG_KEY,
"Got null response for asyId : " + askAsyncResponse.id());
retEngineNode.put(ECConstants.MANAGER_SERVICE_INSTANCE_KEY(), Sender.getThisServiceInstance());
}
private void fillResultEngineNode(Map<String, Object> retEngineNode, EngineNode engineNode) {
retEngineNode.put(
AMConstant.EC_ASYNC_START_RESULT_KEY, AMConstant.EC_ASYNC_START_RESULT_SUCCESS);
retEngineNode.put("serviceInstance", engineNode.getServiceInstance());
if (null == engineNode.getNodeStatus()) {
engineNode.setNodeStatus(NodeStatus.Starting);
}
retEngineNode.put(ECConstants.NODE_STATUS_KEY(), engineNode.getNodeStatus().toString());
retEngineNode.put(ECConstants.EC_TICKET_ID_KEY(), engineNode.getTicketId());
EMNode emNode = engineNode.getEMNode();
if (null != emNode) {
retEngineNode.put(
ECConstants.ECM_SERVICE_INSTANCE_KEY(), engineNode.getEMNode().getServiceInstance());
}
retEngineNode.put(ECConstants.MANAGER_SERVICE_INSTANCE_KEY(), Sender.getThisServiceInstance());
}
@ApiOperation(value = "createEngineConn", response = Message.class)
@ApiOperationSupport(ignoreParameters = {"jsonNode"})
@RequestMapping(path = "/createEngineConn", method = RequestMethod.POST)
public Message createEngineConn(
HttpServletRequest req, @RequestBody EngineCreateRequest engineCreateRequest)
throws IOException, InterruptedException {
String userName = ModuleUserUtils.getOperationUser(req, "createEngineConn");
engineCreateRequest.setUser(userName);
long timeout = engineCreateRequest.getTimeout();
if (timeout <= 0) {
timeout = AMConfiguration.ENGINE_CONN_START_REST_MAX_WAIT_TIME.getValue().toLong();
engineCreateRequest.setTimeout(timeout);
}
logger.info(
"User {} try to create a engineConn with maxStartTime {}. EngineCreateRequest is {}.",
userName,
ByteTimeUtils.msDurationToString(timeout),
engineCreateRequest);
Sender sender = Sender.getSender(Sender.getThisServiceInstance());
EngineNode engineNode;
try {
engineNode = engineCreateService.createEngine(engineCreateRequest, sender);
} catch (LinkisRetryException e) {
logger.error(
"User {} create engineConn failed get retry exception. can be Retry", userName, e);
return Message.error(
String.format(
"Create engineConn failed, caused by %s.", ExceptionUtils.getRootCauseMessage(e)))
.data("canRetry", true);
} catch (Exception e) {
logger.error(String.format("User %s create engineConn failed.", userName), e);
return Message.error(
String.format(
"Create engineConn failed, caused by %s.", ExceptionUtils.getRootCauseMessage(e)));
}
logger.info(
"Finished to create a engineConn for user {}. NodeInfo is {}.", userName, engineNode);
// to transform to a map
Map<String, Object> retEngineNode = new HashMap<>();
fillResultEngineNode(retEngineNode, engineNode);
return Message.ok("create engineConn succeed.").data("engine", retEngineNode);
}
@ApiOperation(value = "getEngineConn", notes = "get engineconn", response = Message.class)
@ApiOperationSupport(ignoreParameters = {"jsonNode"})
@RequestMapping(path = "/getEngineConn", method = RequestMethod.POST)
public Message getEngineConn(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws AMErrorException {
String userName = ModuleUserUtils.getOperationUser(req, "getEngineConn");
ServiceInstance serviceInstance = getServiceInstance(jsonNode);
JsonNode ticketIdNode = jsonNode.get("ticketId");
EngineNode engineNode = null;
try {
engineNode = engineNodeManager.getEngineNodeInfo(serviceInstance);
} catch (Exception e) {
logger.info("Instances {} does not exist", serviceInstance.getInstance());
}
String ecMetrics = null;
if (null == engineNode) {
ECResourceInfoRecord ecInfo = null;
if (null != ticketIdNode) {
try {
ecInfo = ecResourceInfoService.getECResourceInfoRecord(ticketIdNode.asText());
} catch (Exception e) {
logger.info("TicketId {} does not exist", ticketIdNode.asText());
}
}
if (null == ecInfo) {
ecInfo =
ecResourceInfoService.getECResourceInfoRecordByInstance(serviceInstance.getInstance());
}
if (null == ecInfo) {
return Message.error("Instance does not exist " + serviceInstance);
}
if (null == ecMetrics) {
ecMetrics = ecInfo.getMetrics();
}
engineNode = ECResourceInfoUtils.convertECInfoTOECNode(ecInfo);
} else {
ecMetrics = engineNode.getEcMetrics();
}
if (!userName.equals(engineNode.getOwner()) && Configuration.isNotAdmin(userName)) {
return Message.error("You have no permission to access EngineConn " + serviceInstance);
}
Message result = Message.ok().data("engine", engineNode);
result.data(AMConstant.EC_METRICS_KEY, ecMetrics);
return result;
}
@ApiOperation(value = "kill egineconn", notes = "kill engineconn", response = Message.class)
@ApiOperationSupport(ignoreParameters = {"jsonNode"})
@RequestMapping(path = "/killEngineConn", method = RequestMethod.POST)
public Message killEngineConn(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws Exception {
ServiceInstance serviceInstance = getServiceInstance(jsonNode);
String userName = ModuleUserUtils.getOperationUser(req, "killEngineConn:" + serviceInstance);
logger.info("User {} try to kill engineConn {}.", userName, serviceInstance);
EngineNode engineNode = engineNodeManager.getEngineNode(serviceInstance);
if (!userName.equals(engineNode.getOwner()) && Configuration.isNotAdmin(userName)) {
return Message.error("You have no permission to kill EngineConn " + serviceInstance);
}
EngineStopRequest stopEngineRequest = new EngineStopRequest(serviceInstance, userName);
Sender sender = Sender.getSender(Sender.getThisServiceInstance());
engineStopService.stopEngine(stopEngineRequest, sender);
logger.info("Finished to kill engineConn {}.", serviceInstance);
return Message.ok("Kill engineConn succeed.");
}
@ApiOperation(value = "kill egineconns of a ecm", notes = "", response = Message.class)
@ApiImplicitParams({
@ApiImplicitParam(
name = "instance",
dataType = "String",
required = true,
example = "bdp110:9210")
})
@ApiOperationSupport(ignoreParameters = {"param"})
@RequestMapping(path = "/rm/killUnlockEngineByEM", method = RequestMethod.POST)
public Message killUnlockEngine(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws AMErrorException {
JsonNode ecmInstance = jsonNode.get("instance");
if (null == ecmInstance || StringUtils.isBlank(ecmInstance.textValue())) {
throw new AMErrorException(
210003, "instance is null in the parameters of the request(请求参数中【instance】为空)");
}
String operatMsg =
MessageFormat.format("kill the unlock engines of ECM:{0}", ecmInstance.textValue());
String userName = ModuleUserUtils.getOperationUser(req, operatMsg);
if (Configuration.isNotAdmin(userName)) {
throw new AMErrorException(
210003,
"Only admin can kill unlock engine of the specified ecm(只有管理员才能 kill 指定 ecm 下的所有空闲引擎).");
}
Map result = engineStopService.stopUnlockEngineByECM(ecmInstance.textValue(), userName);
return Message.ok("Kill engineConn succeed.").data("result", result);
}
@ApiOperation(
value = "kill eginecon",
notes = "kill one engineconn or more ",
response = Message.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "engineInstance", dataType = "String", example = "bdp110:12295"),
@ApiImplicitParam(
name = "applicationName",
dataType = "String",
example = "linkis-cg-engineconn")
})
@ApiOperationSupport(ignoreParameters = {"param"})
@RequestMapping(path = "/rm/enginekill", method = RequestMethod.POST)
public Message killEngine(HttpServletRequest req, @RequestBody Map<String, String>[] param) {
String userName = ModuleUserUtils.getOperationUser(req, "enginekill");
Sender sender = Sender.getSender(Sender.getThisServiceInstance());
for (Map<String, String> engineParam : param) {
String moduleName = engineParam.get("applicationName");
String engineInstance = engineParam.get("engineInstance");
logger.info("try to kill engine with engineInstance:{}", engineInstance);
EngineStopRequest stopEngineRequest =
new EngineStopRequest(ServiceInstance.apply(moduleName, engineInstance), userName);
engineStopService.stopEngine(stopEngineRequest, sender);
}
logger.info("Finished to kill engines");
return Message.ok("Kill engineConn succeed.");
}
@ApiOperationSupport(ignoreParameters = {"param"})
@ApiImplicitParams({
@ApiImplicitParam(
name = "instances",
dataType = "Array",
example = "[\"bdp110:12295\",\"bdp110:12296\"]")
})
@RequestMapping(path = "/rm/enginekillAsyn", method = RequestMethod.POST)
public Message killEngineAsyn(HttpServletRequest req, @RequestBody JsonNode jsonNode) {
String username = ModuleUserUtils.getOperationUser(req, "enginekill");
String token = ModuleUserUtils.getToken(req);
// check special token
if (StringUtils.isNotBlank(token)) {
if (!Configuration.isAdminToken(token)) {
logger.warn("Token {} has no permission to asyn kill engines.", token);
return Message.error("Token:" + token + " has no permission to asyn kill engines.");
}
} else if (!Configuration.isAdmin(username)) {
logger.warn("User {} has no permission to asyn kill engines.", username);
return Message.error("User:" + username + " has no permission to asyn kill engines.");
}
JsonNode instancesParam = jsonNode.get("instances");
if (instancesParam == null || instancesParam.size() == 0) {
return Message.error(
"instances is null in the parameters of the request(请求参数中【instances】为空)");
}
List<String> instancesList = null;
try {
instancesList =
JsonUtils.jackson()
.readValue(instancesParam.toString(), new TypeReference<List<String>>() {});
} catch (JsonProcessingException e) {
return Message.error("instances parameters parsing failed(请求参数【instances】解析失败)");
}
for (String engineInstance : instancesList) {
String moduleName = GovernanceCommonConf.ENGINE_CONN_MANAGER_SPRING_NAME().getValue();
EngineStopRequest stopEngineRequest =
new EngineStopRequest(ServiceInstance.apply(moduleName, engineInstance), username);
engineStopService.asyncStopEngineWithUpdateMetrics(stopEngineRequest);
}
logger.info("Finished to kill engines");
return Message.ok("Kill engineConn succeed.");
}
@ApiOperation(
value = "listUserEngines",
notes = "get user's engineconn list",
response = Message.class)
@RequestMapping(path = "/listUserEngines", method = RequestMethod.GET)
public Message listUserEngines(HttpServletRequest req) {
String userName = ModuleUserUtils.getOperationUser(req, "listUserEngines");
List<EngineNode> engineNodes = engineInfoService.listUserEngines(userName);
return Message.ok().data("engines", engineNodes);
}
@ApiOperation(
value = "listEMEngines",
notes = "get the list of engineconn under an ECM",
response = Message.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "em", required = false, dataType = "Map", value = "ecm object"),
@ApiImplicitParam(name = "serviceInstance", dataType = "Map"),
@ApiImplicitParam(
name = "applicationName",
dataType = "String",
example = "linkis-cg-engineconnmanager"),
@ApiImplicitParam(name = "instance", required = false, dataType = "String", value = "instance"),
@ApiImplicitParam(name = "emInstance", dataType = "String", example = "bdp110:9102"),
@ApiImplicitParam(name = "engineType", dataType = "String"),
@ApiImplicitParam(name = "nodeStatus", dataType = "String"),
@ApiImplicitParam(name = "owner", dataType = "String", value = "owner")
})
@ApiOperationSupport(ignoreParameters = {"jsonNode"})
@RequestMapping(path = "/listEMEngines", method = RequestMethod.POST)
public Message listEMEngines(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws IOException, AMErrorException {
String username = ModuleUserUtils.getOperationUser(req, "listEMEngines");
if (Configuration.isNotAdmin(username)) {
throw new AMErrorException(
210003, "Only admin can search engine information(只有管理员才能查询所有引擎信息).");
}
AMEMNode amemNode = objectMapper.treeToValue(jsonNode.get("em"), AMEMNode.class);
JsonNode emInstace = jsonNode.get("emInstance");
JsonNode nodeStatus = jsonNode.get("nodeStatus");
JsonNode engineType = jsonNode.get("engineType");
JsonNode owner = jsonNode.get("owner");
List<EngineNode> engineNodes = engineInfoService.listEMEngines(amemNode);
List<AMEngineNodeVo> allengineNodes = AMUtils.copyToAMEngineNodeVo(engineNodes);
if (CollectionUtils.isNotEmpty(allengineNodes)) {
Stream<AMEngineNodeVo> stream = allengineNodes.stream();
if (null != emInstace) {
stream =
stream.filter(
em ->
StringUtils.isNotBlank(em.getInstance())
&& em.getInstance().contains(emInstace.asText()));
}
if (null != nodeStatus && StringUtils.isNotBlank(nodeStatus.asText())) {
stream =
stream.filter(
em ->
null != em.getNodeStatus()
&& em.getNodeStatus().equals(NodeStatus.valueOf(nodeStatus.asText())));
}
if (null != owner && StringUtils.isNotBlank(owner.asText())) {
stream =
stream.filter(
em ->
StringUtils.isNotBlank(em.getOwner())
&& em.getOwner().equalsIgnoreCase(owner.asText()));
}
if (null != engineType && StringUtils.isNotBlank(engineType.asText())) {
stream =
stream.filter(
em ->
StringUtils.isNotBlank(em.getEngineType())
&& em.getEngineType().equalsIgnoreCase(engineType.asText()));
}
allengineNodes = stream.collect(Collectors.toList());
}
return Message.ok().data("engines", allengineNodes);
}
@ApiOperation(
value = "modifyEngineInfo",
notes = "modify engineconn info",
response = Message.class)
@ApiImplicitParams({
@ApiImplicitParam(
name = "applicationName",
dataType = "String",
example = "linkis-cg-engineconn"),
@ApiImplicitParam(
name = "emStatus",
dataType = "String",
example = "Starting,Unlock,Locked,Idle,Busy,Running,ShuttingDown,Failed,Success"),
@ApiImplicitParam(name = "instance", dataType = "String", example = "bdp110:12295"),
@ApiImplicitParam(name = "labels", dataType = "List", required = false, value = "labels"),
@ApiImplicitParam(name = "labelKey", dataType = "String", example = "engineInstance"),
@ApiImplicitParam(name = "stringValue", dataType = "String", example = "linkis-cg:12295"),
@ApiImplicitParam(name = "nodeHealthy", dataType = "String", example = "UnHealthy")
})
@ApiOperationSupport(ignoreParameters = {"jsonNode"})
@RequestMapping(path = "/modifyEngineInfo", method = RequestMethod.PUT)
public Message modifyEngineInfo(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws AMErrorException, LabelErrorException {
String username = ModuleUserUtils.getOperationUser(req, "modifyEngineInfo");
if (Configuration.isNotAdmin(username)) {
throw new AMErrorException(
210003, "Only admin can modify engineConn information(只有管理员才能修改引擎信息).");
}
ServiceInstance serviceInstance = getServiceInstance(jsonNode);
JsonNode labels = jsonNode.get("labels");
Set<String> labelKeySet = new HashSet<>();
if (labels != null) {
ArrayList<Label<?>> newLabelList = new ArrayList<>();
Iterator<JsonNode> iterator = labels.iterator();
while (iterator.hasNext()) {
JsonNode label = iterator.next();
String labelKey = label.get("labelKey").asText();
String stringValue = label.get("stringValue").asText();
Label newLabel = stdLabelBuilderFactory.createLabel(labelKey, stringValue);
if (newLabel instanceof UserModifiable) {
((UserModifiable) newLabel).valueCheck(stringValue);
}
labelKeySet.add(labelKey);
newLabelList.add(newLabel);
}
if (labelKeySet.size() != newLabelList.size()) {
throw new AMErrorException(
210003, "Failed to update label, include repeat label(更新label失败,包含重复label)");
}
nodeLabelService.updateLabelsToNode(serviceInstance, newLabelList);
logger.info("success to update label of instance: " + serviceInstance.getInstance());
}
// 修改引擎健康状态,只支持 Healthy和 UnHealthy
String healthyKey = "Healthy";
String unHealthyKey = "UnHealthy";
JsonNode nodeHealthy = jsonNode.get("nodeHealthy");
if (nodeHealthy != null && healthyKey.equals(nodeHealthy.asText())) {
engineInfoService.updateEngineHealthyStatus(serviceInstance, NodeHealthy.Healthy);
} else if (nodeHealthy != null && unHealthyKey.equals(nodeHealthy.asText())) {
engineInfoService.updateEngineHealthyStatus(serviceInstance, NodeHealthy.UnHealthy);
}
return Message.ok("success to update engine information(更新引擎信息成功)");
}
@ApiOperation(
value = "batchSetEngineToUnHealthy",
notes = "batch set engine to unHealthy",
response = Message.class)
@ApiImplicitParams({
@ApiImplicitParam(
name = "instances",
dataType = "String",
example =
"[{\"instance\":\"bdplinkis1001:38701\",\"engineType\":\"spark\",\"applicationName\":\"linkis-cg-engineconn\"}]")
})
@ApiOperationSupport(ignoreParameters = {"jsonNode"})
@RequestMapping(path = "/batchSetEngineToUnHealthy", method = RequestMethod.POST)
public Message batchSetEngineToUnHealthy(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws AMErrorException {
String username = ModuleUserUtils.getOperationUser(req, "batchSetEngineToUnHealthy");
if (Configuration.isNotAdmin(username)) {
throw new AMErrorException(
210003, "Only admin can modify engineConn healthy info(只有管理员才能修改引擎健康信息).");
}
JsonNode instances = jsonNode.get("instances");
if (instances != null) {
Iterator<JsonNode> iterator = instances.iterator();
while (iterator.hasNext()) {
JsonNode instanceNode = iterator.next();
ServiceInstance serviceInstance = getServiceInstance(instanceNode);
engineInfoService.updateEngineHealthyStatus(serviceInstance, NodeHealthy.UnHealthy);
}
}
logger.info("success to batch update engine status to UnHealthy.");
return Message.ok("success to update engine information(批量更新引擎健康信息成功)");
}
@ApiOperation(
value = "listAllNodeHealthyStatus",
notes = "get all node healthy staus list",
response = Message.class)
@RequestMapping(path = "/listAllNodeHealthyStatus", method = RequestMethod.GET)
public Message listAllNodeHealthyStatus(
HttpServletRequest req,
@RequestParam(value = "onlyEditable", required = false) Boolean onlyEditable) {
NodeStatus[] nodeStatus = NodeStatus.values();
return Message.ok().data("nodeStatus", nodeStatus);
}
@ApiOperation(
value = "executeEngineConnOperation",
notes = "execute engine conn operation",
response = Message.class)
@RequestMapping(path = "/executeEngineConnOperation", method = RequestMethod.POST)
public Message executeEngineConnOperation(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws Exception {
String userName = ModuleUserUtils.getOperationUser(req, "executeEngineConnOperation");
ServiceInstance serviceInstance = getServiceInstance(jsonNode);
logger.info("User {} try to execute Engine Operation {}.", userName, serviceInstance);
EngineNode engineNode = engineNodeManager.getEngineNode(serviceInstance);
if (null == engineNode) {
return Message.ok()
.data("isError", true)
.data("errorMsg", "Ec : " + serviceInstance.toString() + " not found.");
}
if (!userName.equals(engineNode.getOwner()) && Configuration.isNotAdmin(userName)) {
return Message.error("You have no permission to execute Engine Operation " + serviceInstance);
}
Map<String, Object> parameters =
objectMapper.convertValue(
jsonNode.get("parameters"), new TypeReference<Map<String, Object>>() {});
EngineOperateRequest engineOperateRequest = new EngineOperateRequest(userName, parameters);
EngineOperateResponse engineOperateResponse =
engineOperateService.executeOperation(engineNode, engineOperateRequest);
return Message.ok()
.data("result", engineOperateResponse.getResult())
.data("errorMsg", engineOperateResponse.errorMsg())
.data("isError", engineOperateResponse.isError());
}
@ApiOperation(
value = "kill egineconns of a ecm",
notes = "Kill engine after updating configuration",
response = Message.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "creator", dataType = "String", required = true, example = "IDE"),
@ApiImplicitParam(
name = "engineType",
dataType = "String",
required = true,
example = "hive-2.3.3"),
})
@ApiOperationSupport(ignoreParameters = {"param"})
@RequestMapping(path = "/rm/killEngineByUpdateConfig", method = RequestMethod.POST)
public Message killEngineByUpdateConfig(HttpServletRequest req, @RequestBody JsonNode jsonNode)
throws AMErrorException {
String userName = ModuleUserUtils.getOperationUser(req);
String jvmUser = StorageUtils.getJvmUser();
if (jvmUser.equals(userName)) {
return Message.error(
jvmUser + " users do not support this feature (" + jvmUser + " 用户不支持此功能)");
}
JsonNode creator = jsonNode.get("creator");
if (null == creator || StringUtils.isBlank(creator.textValue())) {
return Message.error("instance is null in the parameters of the request(请求参数中【creator】为空)");
}
String creatorStr = Configuration.getGlobalCreator(creator.textValue());
String engineType = "";
if (null != jsonNode.get("engineType")) {
engineType = jsonNode.get("engineType").textValue();
}
if (StringUtils.isNotBlank(engineType)
&& AMConfiguration.isUnAllowKilledEngineType(engineType)) {
return Message.error("multi user engine does not support this feature(多用户引擎不支持此功能)");
}
engineStopService.stopUnlockECByUserCreatorAndECType(userName, creatorStr, engineType);
return Message.ok("Kill engineConn succeed");
}
static ServiceInstance getServiceInstance(JsonNode jsonNode) throws AMErrorException {
String applicationName = jsonNode.get("applicationName").asText();
String instance = jsonNode.get("instance").asText();
if (StringUtils.isEmpty(applicationName)) {
throw new AMErrorException(
AMErrorCode.QUERY_PARAM_NULL.getErrorCode(),
"applicationName cannot be null(请求参数applicationName不能为空)");
}
if (StringUtils.isEmpty(instance)) {
throw new AMErrorException(
AMErrorCode.QUERY_PARAM_NULL.getErrorCode(), "instance cannot be null(请求参数instance不能为空)");
}
return ServiceInstance.apply(applicationName, instance);
}
}
|
oracle/graal | 36,727 | substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/SimulateClassInitializerSupport.java | /*
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.hosted.classinitialization;
import static com.oracle.svm.hosted.classinitialization.SimulateClassInitializerGraphDecoder.adaptForImageHeap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
import org.graalvm.collections.EconomicMap;
import org.graalvm.collections.EconomicSet;
import org.graalvm.nativeimage.ImageSingletons;
import com.oracle.graal.pointsto.BigBang;
import com.oracle.graal.pointsto.flow.AnalysisParsedGraph;
import com.oracle.graal.pointsto.heap.ImageHeapConstant;
import com.oracle.graal.pointsto.meta.AnalysisField;
import com.oracle.graal.pointsto.meta.AnalysisMetaAccess;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.BaseLayerType;
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.phases.InlineBeforeAnalysis;
import com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder;
import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.SVMHost;
import com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider;
import com.oracle.svm.hosted.ameta.FieldValueInterceptionSupport;
import com.oracle.svm.hosted.fieldfolding.MarkStaticFinalFieldInitializedNode;
import com.oracle.svm.hosted.imagelayer.HostedImageLayerBuildingSupport;
import com.oracle.svm.hosted.imagelayer.SVMImageLayerLoader;
import com.oracle.svm.hosted.meta.HostedConstantReflectionProvider;
import com.oracle.svm.hosted.meta.HostedType;
import com.oracle.svm.hosted.phases.InlineBeforeAnalysisGraphDecoderImpl;
import com.oracle.svm.hosted.AbstractAnalysisMetadataTrackingNode;
import com.oracle.svm.util.ClassUtil;
import jdk.graal.compiler.core.common.spi.ConstantFieldProvider;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.DebugContext.Scope;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.nodes.BeginNode;
import jdk.graal.compiler.nodes.ConstantNode;
import jdk.graal.compiler.nodes.EndNode;
import jdk.graal.compiler.nodes.FullInfopointNode;
import jdk.graal.compiler.nodes.MergeNode;
import jdk.graal.compiler.nodes.ReturnNode;
import jdk.graal.compiler.nodes.StartNode;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.UnreachableBeginNode;
import jdk.graal.compiler.nodes.UnreachableControlSinkNode;
import jdk.graal.compiler.nodes.VirtualState;
import jdk.graal.compiler.nodes.java.ExceptionObjectNode;
import jdk.graal.compiler.nodes.java.FinalFieldBarrierNode;
import jdk.graal.compiler.nodes.java.LoadFieldNode;
import jdk.graal.compiler.nodes.java.StoreFieldNode;
import jdk.graal.compiler.nodes.virtual.VirtualObjectNode;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.phases.common.CanonicalizerPhase;
import jdk.graal.compiler.printer.GraalDebugHandlersFactory;
import jdk.graal.compiler.replacements.PEGraphDecoder;
import jdk.vm.ci.meta.JavaConstant;
/**
* The main entry point for simulation of class initializer.
*
* A class initializer is executed exactly once before the first usage of a class. The specification
* requires that this happens as late as possible just before the first usage. But if executing a
* class initializer does not have any side effects, i.e., does not depend on any external state and
* does not modify any external state, then there is no observable difference when already starting
* out with the class pre-initialized at image run time. However, we do not want to really
* initialize the class in the image generator VM, because the class could be used by Feature code
* that runs at image build time, and we do not want to inherit any static state modified by a
* Feature. Therefore, we simulate the class initializer.
*
* A class with a simulated class initializer has the following initialization status: 1) Its
* initialization status in the hosting VM that runs the image generator does not matter. The class
* may or may not be initialized there. But in any case, static field values of the hosting VM are
* not visible at run time. 2) The class starts out as initialized at image run time, i.e., there
* are no run-time class initialization checks necessary and the class initializer itself is not AOT
* compiled. Static field values in the image heap reflect the status after the class initializer.
*
* Simulation determines whether a class initializer is side-effect free and does not depend on
* external state, i.e., if executing the class initializer before the first usage of the class does
* not lead to any observable differences (except timing differences).
*
* Examples of what can be simulated:
* <ul>
* <li>Allocations of instances, and allocations of arrays with a constant length. This is safe
* because a class initializer is a single-execute method, and all loops are unrolled during
* simulation.</li>
* <li>Reads and writes of objects (instances and arrays) that are allocated in the same class
* initializer.</li>
* <li>Reads of immutable state of classes that are simulated themselves or that are initialized at
* image build time.</li>
* <li>Cyclic class initializer dependencies where all members of the cycle can be simulated.</li>
* <li>Arithmetic or conditions that can be constant folded.</li>
* </ul>
*
* Examples of what prevents a class initializer from being simulated:
* <ul>
* <li>Reads or writes of mutable state of another class, i.e., accesses of non-final static fields
* or instance fields, or accesses of arrays that were read from final fields.</li>
* <li>Dependencies on another class that are not simulated themselves or that are not initialized
* at image build time.</li>
* <li>Invokes that cannot be de-virtualized</li>
* <li>Invokes of native methods.</li>
* <li>Loops that cannot be fully unrolled.</li>
* <li>Arithmetic or conditions that cannot be constant folded.</li>
* </ul>
*
* Simulation is implemented using partial evaluation of Graal IR, leveraging
* {@link PEGraphDecoder}. The class initializer itself and any method that partial evaluation
* reaches is parsed using {@link AnalysisParsedGraph}. The parsed graphs are shared with the static
* analysis, i.e., there is no special bytecode parsing (like special graph builder plugins). The
* simulation is similar to {@link InlineBeforeAnalysis}, but with significantly more
* canonicalizations done in {@link SimulateClassInitializerGraphDecoder#doCanonicalizeFixedNode}.
*
* To support cyclic class initializer dependencies, all not-yet-simulated classes referenced by a
* class initializer are handled as part of the same {@link SimulateClassInitializerCluster}. Each
* {@link SimulateClassInitializerClusterMember} goes through states defined in
* {@link SimulateClassInitializerStatus}: Only when all members of a cycle have been analyzed, the
* results for the whole cycle are published, i.e., either all or none of the members are marked as
* simulated.
*
* The graph decoder implementation {@link SimulateClassInitializerGraphDecoder} extends the
* {@link InlineBeforeAnalysisGraphDecoder}, which allows to abort inlining of a method. This "abort
* a particular inlining" is not necessary in "production mode" where such an abort immediately
* marks the class initializer as "simulation not possible". But for diagnostic purposes, a
* {@link #collectAllReasons} mode can be enabled. In this mode, as many reasons as possible are
* collected why simulation is not possible. When users try to make more class initializer
* simulateable, having as many reasons as possible is helpful.
*
* The results of the simulation are available before the static analysis, i.e., if a class
* initializer is simulated it is not seen as a root method by the static analysis. This is
* important because otherwise static final fields in the class would still be seen as written by
* the static analysis. However, it is not allowed to use simulation results already during bytecode
* parsing: since simulation relies on parsing arbitrary methods that might be reachable from a
* class initializer, using simulation results during parsing would lead to cyclic dependencies. In
* the best case that would be bytecode parsing deadlocks, in the worst case it would be
* non-deterministic usage of simulation information depending on the order in which classes are
* analyzed. Therefore, the simulation results are not used by
* {@link AnalysisConstantReflectionProvider} (only by {@link HostedConstantReflectionProvider}) and
* they are not used by {@link AnalysisType#isInitialized} ( only by
* {@link HostedType#isInitialized}). In order to use simulation results before the static analysis,
* the simulation results are used by {@link InlineBeforeAnalysis} (see the implementation of
* {@link InlineBeforeAnalysisGraphDecoderImpl}).
*/
public class SimulateClassInitializerSupport {
protected final ClassInitializationSupport classInitializationSupport = ClassInitializationSupport.singleton();
protected final FieldValueInterceptionSupport fieldValueInterceptionSupport = FieldValueInterceptionSupport.singleton();
protected final SimulateClassInitializerPolicy simulateClassInitializerPolicy;
protected final SimulateClassInitializerConstantFieldProvider simulatedFieldValueConstantFieldProvider;
/** The main data structure that stores all published results of the simulation. */
protected final ConcurrentMap<AnalysisType, SimulateClassInitializerResult> analyzedClasses = new ConcurrentHashMap<>();
protected final boolean enabled = ClassInitializationOptions.SimulateClassInitializer.getValue();
/* Cached value of options to avoid frequent lookup of option values. */
protected final boolean collectAllReasons = ClassInitializationOptions.SimulateClassInitializerCollectAllReasons.getValue();
protected final int maxInlineDepth = ClassInitializationOptions.SimulateClassInitializerMaxInlineDepth.getValue();
protected final int maxLoopIterations = ClassInitializationOptions.SimulateClassInitializerMaxLoopIterations.getValue();
protected final int maxAllocatedBytes = ClassInitializationOptions.SimulateClassInitializerMaxAllocatedBytes.getValue();
private final SVMImageLayerLoader layerLoader;
public static SimulateClassInitializerSupport singleton() {
return ImageSingletons.lookup(SimulateClassInitializerSupport.class);
}
@SuppressWarnings("this-escape")
public SimulateClassInitializerSupport(AnalysisMetaAccess aMetaAccess, SVMHost hostVM) {
simulateClassInitializerPolicy = new SimulateClassInitializerPolicy(hostVM, this);
simulatedFieldValueConstantFieldProvider = new SimulateClassInitializerConstantFieldProvider(aMetaAccess, hostVM, this);
layerLoader = HostedImageLayerBuildingSupport.singleton().getLoader();
}
public boolean isEnabled() {
return enabled;
}
/**
* Initiate the simulation of the class initializer, unless there is already a published result
* available.
* <p>
* The method returns {@code true} if either the simulation succeeded or the type is initialized
* at build time in the host VM, i.e., {@link AnalysisType#isInitialized()} returns
* {@code true}. In both cases the type starts out as "initialized" at image run time.
* <p>
* In layered image builds the simulation result is loaded from previous layers, if available.
*/
public boolean trySimulateClassInitializer(BigBang bb, AnalysisType type) {
var existingResult = lookupPublishedSimulateClassInitializerResult(type);
if (existingResult != null) {
return existingResult.simulatedInitialized;
}
var debug = new DebugContext.Builder(bb.getOptions()).build();
try (var _ = debug.scope("SimulateClassInitializer", type)) {
/* Entry point to the analysis: start a new cluster of class initializers. */
var cluster = new SimulateClassInitializerCluster(this, bb);
boolean result = trySimulateClassInitializer(debug, type, cluster, null);
for (var clusterMember : cluster.clusterMembers.getValues()) {
VMError.guarantee(clusterMember.status.published, "All members of the cluster must be published at the end of the analysis");
}
return result;
} catch (Throwable ex) {
throw debug.handle(ex);
}
}
boolean trySimulateClassInitializer(DebugContext debug, AnalysisType type, SimulateClassInitializerClusterMember dependant) {
var existingResult = lookupPublishedSimulateClassInitializerResult(type);
if (existingResult != null) {
return existingResult.simulatedInitialized;
}
return trySimulateClassInitializer(debug, type, dependant.cluster, dependant);
}
/**
* Tries to constant-fold the field access based on results from the class initializer
* simulation.
*/
public ConstantNode tryCanonicalize(BigBang bb, LoadFieldNode node) {
var field = (AnalysisField) node.field();
var simulatedFieldValue = getSimulatedFieldValue(field);
if (simulatedFieldValue == null) {
return null;
}
/*
* We need to go via a ConstantFieldProvider to produce the ConstantNode so that stable
* array dimensions are properly computed. But we cannot use the ConstantFieldProvider from
* the providers, because our regular implementation only folds static fields for types
* where isInitialized() returns true. For our simulated types, AnalysisType.isInitialized()
* is still false because that method needs to return a stable value that does not change
* while the analysis is running.
*/
return simulatedFieldValueConstantFieldProvider.readConstantField(field, new ConstantFieldProvider.ConstantFieldTool<>() {
@Override
public JavaConstant readValue() {
return simulatedFieldValue;
}
@Override
public JavaConstant getReceiver() {
/* We are only reading static fields. */
return null;
}
@Override
public Object getReason() {
return node.getNodeSourcePosition();
}
@Override
public ConstantNode foldConstant(JavaConstant constant) {
return constant == null ? null : ConstantNode.forConstant(constant, bb.getMetaAccess());
}
@Override
public ConstantNode foldStableArray(JavaConstant constant, int stableDimensions, boolean isDefaultStable) {
return constant == null ? null : ConstantNode.forConstant(constant, stableDimensions, isDefaultStable, bb.getMetaAccess());
}
@Override
public OptionValues getOptions() {
return bb.getOptions();
}
});
}
/**
* Returns the simulated value of a static field, or null if no such value is available.
*/
public JavaConstant getSimulatedFieldValue(AnalysisField field) {
if (!enabled || !field.isStatic()) {
return null;
}
var existingResult = analyzedClasses.get(field.getDeclaringClass());
if (existingResult == null || !existingResult.simulatedInitialized) {
return null;
}
var simulatedFieldValue = existingResult.staticFieldValues.get(field);
if (simulatedFieldValue != null) {
return simulatedFieldValue;
} else {
/*
* The JVM specification requires that all static final fields are explicitly
* initialized, even when they have the default value. So we should never hit this path
* for a static final field. But languages like Scala violate the specification and
* write static final fields outside the class initializer. Therefore, we must return
* null here to indicate that we do not know the value yet.
*/
return null;
}
}
/**
* Returns {@code true} if the type was either successfully simulated or it is initialized at
* build time in the host VM, i.e., {@link AnalysisType#isInitialized()} returns {@code true}.
*/
public boolean isSimulatedOrInitializedAtBuildTime(AnalysisType type) {
var existingResult = lookupPublishedSimulateClassInitializerResult(type);
if (existingResult != null) {
return existingResult.simulatedInitialized;
}
return false;
}
/** Returns {@code true} iff the type was successfully simulated. */
public boolean isSuccessfulSimulation(AnalysisType type) {
var existingResult = lookupPublishedSimulateClassInitializerResult(type);
if (existingResult != null && existingResult != SimulateClassInitializerResult.INITIALIZED_HOSTED) {
return existingResult.simulatedInitialized;
}
return false;
}
/** Returns {@code true} if the type simulation failed. */
public boolean isFailedSimulation(AnalysisType type) {
var existingResult = lookupPublishedSimulateClassInitializerResult(type);
return existingResult == SimulateClassInitializerResult.FAILED_SIMULATED_INITIALIZED;
}
private SimulateClassInitializerResult lookupPublishedSimulateClassInitializerResult(AnalysisType type) {
if (!type.isLinked()) {
/* We try linking the AnalysisType when we create it. This means linking failed. */
return SimulateClassInitializerResult.NOT_SIMULATED_INITIALIZED;
} else if (type.isInitialized()) {
/*
* Type is registered as "initialize at build time", so class initializer is already
* executed by the host VM that runs the image generator.
*/
return SimulateClassInitializerResult.INITIALIZED_HOSTED;
}
VMError.guarantee(!type.isArray() && !type.isPrimitive(), "array and primitive types are always initialized at build time");
if (!enabled) {
return SimulateClassInitializerResult.NOT_SIMULATED_INITIALIZED;
}
if (type.isInBaseLayer()) {
if (type.getWrapped() instanceof BaseLayerType) {
return SimulateClassInitializerResult.NOT_SIMULATED_INITIALIZED;
}
/* Record type's simulation result loaded from the previous layer. */
var sharedLayerSimulation = layerLoader.getSimulationResult(type);
if (sharedLayerSimulation != null) {
if (sharedLayerSimulation.successful()) {
var existingResult = recordSuccessfulSimulation(type, sharedLayerSimulation.staticFieldValues());
assert existingResult == null || existingResult.simulatedInitialized : "Found unexpected simulation result.";
} else {
var existingResult = recordFailedSimulation(type);
assert existingResult == null || !existingResult.simulatedInitialized : "Found unexpected simulation result.";
}
}
}
return analyzedClasses.get(type);
}
boolean trySimulateClassInitializer(DebugContext debug, AnalysisType type, SimulateClassInitializerCluster cluster, SimulateClassInitializerClusterMember dependant) {
var existingClusterMember = cluster.clusterMembers.get(type);
if (existingClusterMember != null) {
assert !existingClusterMember.status.published : type + ": " + existingClusterMember.status;
/* Cycle in class initializer dependencies. */
dependant.dependencies.add(existingClusterMember);
return false;
}
var clusterMember = new SimulateClassInitializerClusterMember(cluster, type);
if (dependant != null) {
dependant.dependencies.add(clusterMember);
}
checkStrictlyInitializeAtRunTime(clusterMember);
if (clusterMember.notInitializedReasons.isEmpty() || collectAllReasons) {
addSuperDependencies(debug, clusterMember);
}
if (clusterMember.notInitializedReasons.isEmpty() || collectAllReasons) {
addClassInitializerDependencies(clusterMember);
}
clusterMember.status = SimulateClassInitializerStatus.INIT_CANDIDATE;
EconomicSet<SimulateClassInitializerClusterMember> transitiveDependencies = EconomicSet.create();
boolean dependenciesMissing = collectTransitiveDependencies(clusterMember, transitiveDependencies);
if (dependenciesMissing) {
/* Cycle is not fully processed yet, delay publishing results. */
return false;
}
boolean allDependenciesSimulated = true;
for (var dependency : transitiveDependencies) {
assert dependency.status != SimulateClassInitializerStatus.COLLECTING_DEPENDENCIES : dependency.type + ": " + dependency.status;
if (dependency.status == SimulateClassInitializerStatus.PUBLISHED_AS_NOT_INITIALIZED || dependency.notInitializedReasons.size() > 0) {
allDependenciesSimulated = false;
break;
}
}
publishResults(debug, allDependenciesSimulated, transitiveDependencies);
return allDependenciesSimulated;
}
private void checkStrictlyInitializeAtRunTime(SimulateClassInitializerClusterMember clusterMember) {
var clazz = clusterMember.type.getJavaClass();
if (classInitializationSupport.specifiedInitKindFor(clazz) == InitKind.RUN_TIME && classInitializationSupport.isStrictlyDefined(clazz)) {
/*
* The class itself (not just the whole package) is registered as
* "initialize at run time", so we honor that registration. There was hopefully a good
* reason for the explicit registration.
*/
clusterMember.notInitializedReasons.add("Class is strictly defined as initialize at run time");
}
}
private void addSuperDependencies(DebugContext debug, SimulateClassInitializerClusterMember clusterMember) {
if (clusterMember.type.isInterface()) {
/*
* Initialization of an interface does not trigger initialization of any
* super-interface, even in the case of default methods.
*/
return;
}
var supertype = clusterMember.type.getSuperclass();
if (supertype != null) {
addDependency(debug, clusterMember, supertype, supertype);
}
addInterfaceDependencies(debug, clusterMember.type, clusterMember);
}
private void addInterfaceDependencies(DebugContext debug, AnalysisType type, SimulateClassInitializerClusterMember clusterMember) {
for (var iface : type.getInterfaces()) {
if (iface.declaresDefaultMethods()) {
/*
* An interface that declares default methods is initialized when a class
* implementing it is initialized.
*/
addDependency(debug, clusterMember, iface, iface);
} else {
/*
* An interface that does not declare default methods is independent from a class
* that implements it, i.e., the interface can still be uninitialized even when the
* class is initialized.
*/
addInterfaceDependencies(debug, iface, clusterMember);
}
}
}
private void addDependency(DebugContext debug, SimulateClassInitializerClusterMember clusterMember, AnalysisType newDependency, Object reason) {
var dependencyResult = lookupPublishedSimulateClassInitializerResult(newDependency);
if (dependencyResult != null) {
if (!dependencyResult.simulatedInitialized) {
clusterMember.notInitializedReasons.add(reason);
}
return;
}
trySimulateClassInitializer(debug, newDependency, clusterMember.cluster, clusterMember);
}
private void addClassInitializerDependencies(SimulateClassInitializerClusterMember clusterMember) {
var classInitializer = clusterMember.type.getClassInitializer();
if (classInitializer == null) {
return;
}
VMError.guarantee(!classInitializer.isInBaseLayer(), "Trying to simulate a class initializer already simulated in a previous layer.");
StructuredGraph graph;
try {
graph = decodeGraph(clusterMember, classInitializer);
} catch (SimulateClassInitializerAbortException ignored) {
VMError.guarantee(!clusterMember.notInitializedReasons.isEmpty(), "Reason must be added before throwing the abort-exception");
return;
}
for (Node node : graph.getNodes()) {
processEffectsOfNode(clusterMember, node);
}
}
private StructuredGraph decodeGraph(SimulateClassInitializerClusterMember clusterMember, AnalysisMethod classInitializer) {
var bb = clusterMember.cluster.bb;
var analysisParsedGraph = classInitializer.ensureGraphParsed(bb);
var description = new DebugContext.Description(classInitializer, ClassUtil.getUnqualifiedName(classInitializer.getClass()) + ":" + classInitializer.getId());
var debug = new DebugContext.Builder(bb.getOptions(), new GraalDebugHandlersFactory(bb.getProviders(classInitializer).getSnippetReflection())).description(description).build();
var result = new StructuredGraph.Builder(bb.getOptions(), debug)
.method(classInitializer)
.trackNodeSourcePosition(analysisParsedGraph.getEncodedGraph().trackNodeSourcePosition())
.recordInlinedMethods(analysisParsedGraph.getEncodedGraph().isRecordingInlinedMethods())
.build();
try (var _ = debug.scope("GraphDecoderSimulateClassInitializer", result)) {
var decoder = createGraphDecoder(clusterMember, bb, result);
decoder.decode(classInitializer);
debug.dump(DebugContext.BASIC_LEVEL, result, "SimulateClassInitializer after decode");
CanonicalizerPhase.create().apply(result, clusterMember.cluster.providers);
return result;
} catch (Throwable ex) {
throw debug.handle(ex);
}
}
protected SimulateClassInitializerGraphDecoder createGraphDecoder(SimulateClassInitializerClusterMember clusterMember, BigBang bb, StructuredGraph result) {
return new SimulateClassInitializerGraphDecoder(bb, simulateClassInitializerPolicy, clusterMember, result);
}
private static void processEffectsOfNode(SimulateClassInitializerClusterMember clusterMember, Node node) {
if (node instanceof StartNode || node instanceof BeginNode || node instanceof UnreachableBeginNode || node instanceof UnreachableControlSinkNode || node instanceof FullInfopointNode) {
/* Boilerplate nodes in a graph that do not lead to any machine code. */
return;
} else if (node instanceof ReturnNode returnNode) {
assert returnNode.result() == null : "Class initializer always has return type void";
return;
} else if (node instanceof VirtualState) {
/* All kinds of FrameState can be ignored. */
return;
} else if (node instanceof VirtualObjectNode) {
/*
* Can still be referenced by a FrameState even when all allocations were partially
* evaluated into image heap constants.
*/
return;
} else if (node instanceof ConstantNode) {
return;
} else if (node instanceof FinalFieldBarrierNode) {
return;
} else if (node instanceof MarkStaticFinalFieldInitializedNode) {
return;
} else if (node instanceof StoreFieldNode storeFieldNode) {
var field = (AnalysisField) storeFieldNode.field();
if (field.isStatic() && field.getDeclaringClass().equals(clusterMember.type)) {
var constantValue = storeFieldNode.value().asJavaConstant();
if (constantValue != null) {
if (constantValue instanceof ImageHeapConstant imageHeapConstant && field.isFinal()) {
imageHeapConstant.setOrigin(field);
}
// We use the java kind here and not the storage kind since that's what the
// users of (Analysis)ConstantReflectionProvider expect.
clusterMember.staticFieldValues.put(field, adaptForImageHeap(constantValue, field.getJavaKind()));
return;
}
}
} else if (node instanceof AbstractAnalysisMetadataTrackingNode) {
/* This node should not affect image semantics as it gets removed after analysis. */
return;
}
clusterMember.notInitializedReasons.add(node);
}
/**
* To enable logging use {@code -H:Log=SimulateClassInitializer} to match the {@link Scope}
* opened by {@link #trySimulateClassInitializer(BigBang, AnalysisType)}.
*/
private void publishResults(DebugContext debug, boolean simulatedInitialized, EconomicSet<SimulateClassInitializerClusterMember> transitiveDependencies) {
for (var clusterMember : transitiveDependencies) {
if (clusterMember.status.published) {
continue;
}
assert clusterMember.status == SimulateClassInitializerStatus.INIT_CANDIDATE : clusterMember.type + ": " + clusterMember.status;
SimulateClassInitializerResult existingResult;
if (simulatedInitialized) {
assert clusterMember.notInitializedReasons.isEmpty() : clusterMember.type + ": " + clusterMember.notInitializedReasons;
if (debug.isLogEnabled(DebugContext.BASIC_LEVEL)) {
debug.log("simulated: %s", clusterMember.type.toJavaName(true));
}
existingResult = recordSuccessfulSimulation(clusterMember.type, clusterMember.staticFieldValues);
clusterMember.status = SimulateClassInitializerStatus.PUBLISHED_AS_INITIALIZED;
} else {
if (debug.isLogEnabled(DebugContext.BASIC_LEVEL)) {
debug.log("not simulated: %s:%n %s", clusterMember.type.toJavaName(true),
clusterMember.notInitializedReasons.stream()
.map(reason -> reasonToString(clusterMember.cluster.providers, reason))
.filter(s -> s != null && !s.isEmpty())
.collect(Collectors.joining(System.lineSeparator() + " ")));
}
existingResult = recordFailedSimulation(clusterMember.type);
clusterMember.status = SimulateClassInitializerStatus.PUBLISHED_AS_NOT_INITIALIZED;
}
if (existingResult != null && simulatedInitialized != existingResult.simulatedInitialized) {
StringBuilder msg = new StringBuilder("mismatch with existing registration: ").append(clusterMember.type.toJavaName(true))
.append(", existingResult: ").append(existingResult.simulatedInitialized)
.append(", new: ").append(simulatedInitialized)
.append(System.lineSeparator()).append("Cluster members:");
for (var m : clusterMember.cluster.clusterMembers.getValues()) {
msg.append(System.lineSeparator()).append(" ").append(m.type.toJavaName(true)).append(": ").append(m.status)
.append(", ").append(m.staticFieldValues.size())
.append(", ").append(m.notInitializedReasons.isEmpty() ? "(no reasons)" : reasonToString(clusterMember.cluster.providers, m.notInitializedReasons.get(0)));
}
throw VMError.shouldNotReachHere(msg.toString());
}
}
}
private SimulateClassInitializerResult recordFailedSimulation(AnalysisType type) {
return recordSimulationResult(type, SimulateClassInitializerResult.FAILED_SIMULATED_INITIALIZED);
}
private SimulateClassInitializerResult recordSuccessfulSimulation(AnalysisType type, EconomicMap<AnalysisField, JavaConstant> staticFieldValues) {
return recordSimulationResult(type, SimulateClassInitializerResult.forInitialized(staticFieldValues));
}
private SimulateClassInitializerResult recordSimulationResult(AnalysisType type, SimulateClassInitializerResult simulationResult) {
return analyzedClasses.putIfAbsent(type, simulationResult);
}
private boolean collectTransitiveDependencies(SimulateClassInitializerClusterMember clusterMember, EconomicSet<SimulateClassInitializerClusterMember> transitiveDependencies) {
if (clusterMember.status == SimulateClassInitializerStatus.COLLECTING_DEPENDENCIES) {
return true;
} else if (clusterMember.status.published) {
transitiveDependencies.add(clusterMember);
/*
* No need to follow any transitive dependencies, that was done when the cluster member
* was published.
*/
} else {
assert clusterMember.status == SimulateClassInitializerStatus.INIT_CANDIDATE : clusterMember.type + ": " + clusterMember.status;
if (transitiveDependencies.add(clusterMember)) {
for (var dependency : clusterMember.dependencies) {
if (collectTransitiveDependencies(dependency, transitiveDependencies)) {
return true;
}
}
}
}
return false;
}
private static String reasonToString(HostedProviders providers, Object reason) {
if (reason instanceof AnalysisType type) {
return "superclass/interface: " + type.toJavaName(true);
} else if (reason instanceof EnsureClassInitializedNode node && node.constantTypeOrNull(providers.getConstantReflection()) != null) {
return "class initializer dependency: " + node.constantTypeOrNull(providers.getConstantReflection()).toJavaName(true) +
" " + node.getNodeSourcePosition();
} else if (reason instanceof Node node) {
if (node instanceof BeginNode || node instanceof ExceptionObjectNode || node instanceof MergeNode || node instanceof EndNode) {
/* Filter out uninteresting nodes to keep the reason printing short. */
return null;
} else {
return "node " + node + " " + node.getNodeSourcePosition();
}
} else {
return String.valueOf(reason);
}
}
public ClassInitializationSupport getClassInitializationSupport() {
return classInitializationSupport;
}
}
|
apache/mina-sshd | 36,494 | sshd-core/src/main/java/org/apache/sshd/core/CoreModuleProperties.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sshd.core;
import java.io.IOException;
import java.nio.charset.Charset;
import java.time.Duration;
import org.apache.sshd.client.config.keys.ClientIdentityLoader;
import org.apache.sshd.common.Property;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.OsUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.auth.WelcomeBannerPhase;
import org.apache.sshd.server.channel.ChannelDataReceiver;
/**
* Configurable properties for sshd-core.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public final class CoreModuleProperties {
/**
* Value that can be set in order to control the type of authentication channel being requested when forwarding a
* PTY session.
*/
public static final Property<String> PROXY_AUTH_CHANNEL_TYPE
= Property.string("ssh-agent-factory-proxy-auth-channel-type", "auth-agent-req@openssh.com");
/**
* See {@link org.apache.sshd.agent.local.ProxyAgentFactory#getChannelForwardingFactories}
*/
public static final Property<Boolean> PREFER_UNIX_AGENT
= Property.bool("ssh-prefer-unix-agent", OsUtils.isUNIX());
/**
* Value that can be set on the {@link org.apache.sshd.common.FactoryManager} or the session to configure the
* channel open timeout value (millis).
*/
public static final Property<Duration> CHANNEL_OPEN_TIMEOUT
= Property.duration("ssh-agent-server-channel-open-timeout", Duration.ofSeconds(30));
/**
* Value used to configure the type of proxy forwarding channel to be used. See also
* https://tools.ietf.org/html/draft-ietf-secsh-agent-02
*/
public static final Property<String> PROXY_CHANNEL_TYPE
= Property.string("ssh-agent-server-channel-proxy-type", "auth-agent@openssh.com");
/**
* Property that can be set on the {@link Session} in order to control the authentication timeout (millis).
*/
public static final Property<Duration> AUTH_SOCKET_TIMEOUT
= Property.duration("ssh-agent-server-proxy-auth-socket-timeout", Duration.ofHours(1));
public static final int DEFAULT_FORWARDER_BUF_SIZE = 1024;
public static final int MIN_FORWARDER_BUF_SIZE = 127;
public static final int MAX_FORWARDER_BUF_SIZE = 32767;
/**
* Property that can be set on the factory manager in order to control the buffer size used to forward data from the
* established channel
*
* @see #MIN_FORWARDER_BUF_SIZE
* @see #MAX_FORWARDER_BUF_SIZE
* @see #DEFAULT_FORWARDER_BUF_SIZE
*/
public static final Property<Integer> FORWARDER_BUFFER_SIZE
= Property.integer("channel-agent-fwd-buf-size", DEFAULT_FORWARDER_BUF_SIZE);
/**
* Ordered comma separated list of authentications methods. Authentications methods accepted by the server will be
* tried in the given order. If not configured or {@code null}/empty, then the session's
* {@link org.apache.sshd.client.ClientAuthenticationManager#getUserAuthFactories()} is used as-is
*/
public static final Property<String> PREFERRED_AUTHS
= Property.string("preferred-auths");
/**
* Specifies the number of interactive attempts at password or keyboard-interactive user authentication before
* giving up. The argument to this keyword must be an integer; if <= 0, the value 1 is substituted.
*/
public static final Property<Integer> PASSWORD_PROMPTS
= Property.integer("password-prompts", 3);
/**
* Key used to retrieve the value of the client identification string. If set, then it is <U>appended</U> to the
* (standard) "SSH-2.0-" prefix. Otherwise a default is sent that consists of "SSH-2.0-" plus
* the current SSHD artifact name and version in uppercase - e.g., "SSH-2.0-APACHE-SSHD-1.0.0"
*/
public static final Property<String> CLIENT_IDENTIFICATION
= Property.string("client-identification");
/**
* Whether to send the identification string immediately upon session connection being established or wait for the
* server's identification before sending our own.
*
* @see <A HREF="https://tools.ietf.org/html/rfc4253#section-4.2">RFC 4253 - section 4.2 - Protocol Version
* Exchange</A>
*/
public static final Property<Boolean> SEND_IMMEDIATE_IDENTIFICATION
= Property.bool("send-immediate-identification", true);
/**
* Whether to send {@code SSH_MSG_KEXINIT} immediately after sending the client identification string or wait until
* the severer's one has been received.
*
* @see #SEND_IMMEDIATE_IDENTIFICATION
*/
public static final Property<Boolean> SEND_IMMEDIATE_KEXINIT
= Property.bool("send-immediate-kex-init", true);
/**
* Whether allowed to fall back to DH group with SHA-1 KEX if exhausted all available primes for SHA-256.
*/
public static final Property<Boolean> ALLOW_DHG1_KEX_FALLBACK
= Property.bool("allow-dhg1-kex-fallback", false);
/**
* Unused.
*
* @deprecated since 2.14.0
*/
@Deprecated
public static final Property<Duration> KEX_PROPOSAL_SETUP_TIMEOUT
= Property.duration("kex-proposal-setup-timeout", Duration.ZERO);
/**
* Key used to set the heartbeat interval in milliseconds (0 to disable = default)
*/
public static final Property<Duration> HEARTBEAT_INTERVAL
= Property.duration("heartbeat-interval", Duration.ZERO);
/**
* Key used to check the heartbeat request that should be sent to the server
*/
public static final Property<String> HEARTBEAT_REQUEST
= Property.string("heartbeat-request", "keepalive@sshd.apache.org");
/**
* Key used to indicate that the heartbeat request is also expecting a reply - time in <U>milliseconds</U> to wait
* for the reply. If non-positive then no reply is expected (nor requested).
*
* @deprecated since 2.13.0, use {@link #HEARTBEAT_NO_REPLY_MAX} instead
*/
@Deprecated
public static final Property<Duration> HEARTBEAT_REPLY_WAIT
= Property.durationSec("heartbeat-reply-wait", Duration.ofMinutes(5));
/**
* Key to set the maximum number of heartbeat messages to send without having received a reply. If > 0, heartbeat
* messages are sent with a flag that requires the peer to reply. The session will be killed if
* {@code HEARTBEAT_NO_REPLY_MAX} heartbeats have been sent without having received a reply. If <= 0, heartbeat
* messages will be sent, but no reply is requested or expected, and the client will not kill the session.
*
* @since 2.13.0
*/
public static final Property<Integer> HEARTBEAT_NO_REPLY_MAX = Property.integer("heartbeat-no-reply-max", 0);
/**
* Whether to ignore invalid identities files when pre-initializing the client session
*
* @see ClientIdentityLoader#isValidLocation(org.apache.sshd.common.NamedResource)
*/
public static final Property<Boolean> IGNORE_INVALID_IDENTITIES
= Property.bool("ignore-invalid-identities", true);
/**
* Defines if we should abort in case we encounter an invalid (e.g. expired) openssh certificate.
*/
public static final Property<Boolean> ABORT_ON_INVALID_CERTIFICATE
= Property.bool("abort-on-invalid-certificate", true);
/**
* As per RFC-4256:
*
* The language tag is deprecated and SHOULD be the empty string. It may be removed in a future revision of this
* specification. Instead, the server SHOULD select the language to be used based on the tags communicated during
* key exchange
*/
public static final Property<String> INTERACTIVE_LANGUAGE_TAG
= Property.string("kb-client-interactive-language-tag", "");
/**
* As per RFC-4256:
*
* The submethods field is included so the user can give a hint of which actual methods to use. It is a
* comma-separated list of authentication submethods (software or hardware) that the user prefers. If the client has
* knowledge of the submethods preferred by the user, presumably through a configuration setting, it MAY use the
* submethods field to pass this information to the server. Otherwise, it MUST send the empty string.
*
* The actual names of the submethods is something the user and the server need to agree upon.
*
* Server interpretation of the submethods field is implementation- dependent.
*/
public static final Property<String> INTERACTIVE_SUBMETHODS
= Property.string("kb-client-interactive-sub-methods", "");
/**
* Configure whether reply for the "exec" request is required
*/
public static final Property<Boolean> REQUEST_EXEC_REPLY
= Property.bool("channel-exec-want-reply", false);
/**
* On some platforms, a call to {@ode System.in.read(new byte[65536], 0, 32768)} always throws an
* {@link IOException}. So we need to protect against that and chunk the call into smaller calls. This problem was
* found on Windows, JDK 1.6.0_03-b05.
*/
public static final Property<Integer> INPUT_STREAM_PUMP_CHUNK_SIZE
= Property.integer("stdin-pump-chunk-size", 1024);
/**
* Configure whether reply for the "shell" request is required
*/
public static final Property<Boolean> REQUEST_SHELL_REPLY
= Property.bool("channel-shell-want-reply", false);
/**
* Configure whether reply for the "subsystem&quoot; request is required
*
* <P>
* Default value for {@link #REQUEST_SUBSYSTEM_REPLY} - according to
* <A HREF="https://tools.ietf.org/html/rfc4254#section-6.5">RFC4254 section 6.5:</A>
* </P>
* <P>
* It is RECOMMENDED that the reply to these messages be requested and checked.
* </P>
*/
public static final Property<Boolean> REQUEST_SUBSYSTEM_REPLY
= Property.bool("channel-subsystem-want-reply", true);
public static final Property<Integer> PROP_DHGEX_CLIENT_MIN_KEY
= Property.integer("dhgex-client-min");
public static final Property<Integer> PROP_DHGEX_CLIENT_MAX_KEY
= Property.integer("dhgex-client-max");
public static final Property<Integer> PROP_DHGEX_CLIENT_PRF_KEY
= Property.integer("dhgex-client-prf");
public static final long DEFAULT_WINDOW_SIZE = 0x200000L;
/**
* Key used to retrieve the value of the channel window size in the configuration properties map.
*/
public static final Property<Long> WINDOW_SIZE
= Property.long_("window-size", DEFAULT_WINDOW_SIZE);
/**
* Key used to retrieve timeout (msec.) to wait for data to become available when reading from a channel. If not set
* or non-positive then infinite value is assumed
*/
public static final Property<Duration> WINDOW_TIMEOUT
= Property.duration("window-timeout", Duration.ZERO);
/**
* Key used when creating a {@code BufferedIoOutputStream} in order to specify max. allowed unwritten pending bytes.
* If this value is exceeded then the code waits up to {@link #BUFFERED_IO_OUTPUT_MAX_PENDING_WRITE_WAIT} for the
* pending data to be written and thus make room for the new request.
*/
public static final Property<Integer> BUFFERED_IO_OUTPUT_MAX_PENDING_WRITE_SIZE
= Property.integer("buffered-io-output-max-pending-write-size",
SshConstants.SSH_REQUIRED_PAYLOAD_PACKET_LENGTH_SUPPORT * 8);
/**
* Key used when creating a {@code BufferedIoOutputStream} in order to specify max. wait time (msec.) for pending
* writes to be completed before enqueuing a new request
*
* @see #BUFFERED_IO_OUTPUT_MAX_PENDING_WRITE_SIZE
*/
public static final Property<Duration> BUFFERED_IO_OUTPUT_MAX_PENDING_WRITE_WAIT
= Property.duration("buffered-io-output-max-pending-write-wait", Duration.ofSeconds(30L));
public static final long DEFAULT_MAX_PACKET_SIZE = 0x8000L;
/**
* Key used to retrieve the value of the maximum packet size in the configuration properties map.
*/
public static final Property<Long> MAX_PACKET_SIZE
= Property.long_("packet-size", DEFAULT_MAX_PACKET_SIZE);
public static final long DEFAULT_LIMIT_PACKET_SIZE = Integer.MAX_VALUE / 4L;
/**
* A safety value that is designed to avoid an attack that uses large channel packet sizes
*/
public static final Property<Long> LIMIT_PACKET_SIZE
= Property.long_("max-packet-size", DEFAULT_LIMIT_PACKET_SIZE);
/**
* Number of NIO worker threads to use.
*/
public static final Property<Integer> NIO_WORKERS
= Property.validating(Property.integer("nio-workers", Runtime.getRuntime().availableProcessors() + 1),
w -> ValidateUtils.checkTrue(w > 0, "Number of NIO workers must be positive: %d", w));
/**
* Key used to retrieve the value of the timeout after which it will close the connection if the other side has not
* been authenticated - in milliseconds.
*/
public static final Property<Duration> AUTH_TIMEOUT
= Property.duration("auth-timeout", Duration.ofMinutes(2));
/**
* Key used to retrieve the value of idle timeout after which it will close the connection - in milliseconds.
*/
public static final Property<Duration> IDLE_TIMEOUT
= Property.duration("idle-timeout", Duration.ofMinutes(10));
/**
* Key used to retrieve the value of the socket connect time-out.
* <p>
* Connection time-outs are generally handled in Apache MINA SSHD at the application level via
* {@link org.apache.sshd.client.future.ConnectFuture}.{@link org.apache.sshd.common.future.VerifiableFuture#verify(Duration, org.apache.sshd.common.future.CancelOption...)
* verify()}. However, the underlying I/O library may have its own connection time-out. By setting this property on
* an {@link org.apache.sshd.client.SshClient} or {@link org.apache.sshd.server.SshServer}, users can explicitly set
* this I/O connection time-out to any value. If the duration is zero or negative, or the property is not set on the
* client or server, the default of the I/O library used is in effect. These defaults are:
* </p>
* <table>
* <tr>
* <th>I/O back-end</th>
* <th>Default connection time-out</th>
* </tr>
* <tr>
* <td>NIO2</td>
* <td>infinite</td>
* </tr>
* <tr>
* <td>MINA</td>
* <td>1 minute</td>
* </tr>
* <tr>
* <td>Netty</td>
* <td>30 seconds</td>
* </tr>
* </table>
* <p>
* The default value of this property is 1 minute.
* </p>
*/
public static final Property<Duration> IO_CONNECT_TIMEOUT = Property.duration("io-connect-timeout", Duration.ofMinutes(1));
/**
* Key used to retrieve the value of the socket read timeout for NIO2 session implementation - in milliseconds.
*/
public static final Property<Duration> NIO2_READ_TIMEOUT
= Property.duration("nio2-read-timeout", Duration.ZERO);
/**
* Minimum NIO2 write wait timeout for a single outgoing packet - in milliseconds
*/
public static final Property<Duration> NIO2_MIN_WRITE_TIMEOUT
= Property.duration("nio2-min-write-timeout", Duration.ofSeconds(30L));
/**
* Key used to retrieve the value of the disconnect timeout which is used when a disconnection is attempted. If the
* disconnect message has not been sent before the timeout, the underlying socket will be forcibly closed - in
* milliseconds.
*/
public static final Property<Duration> DISCONNECT_TIMEOUT
= Property.duration("disconnect-timeout", Duration.ofSeconds(10));
/**
* Key used to configure the timeout used when writing a close request on a channel. If the message can not be
* written before the specified timeout elapses, the channel will be immediately closed. In milliseconds.
*/
public static final Property<Duration> CHANNEL_CLOSE_TIMEOUT
= Property.duration("channel-close-timeout", Duration.ofSeconds(5));
/**
* Timeout (milliseconds) to wait for client / server stop request if immediate stop requested.
*/
public static final Property<Duration> STOP_WAIT_TIME
= Property.duration("stop-wait-time", Duration.ofMinutes(1));
/**
* Socket backlog. See {@link java.nio.channels.AsynchronousServerSocketChannel#bind(java.net.SocketAddress, int)}
*/
public static final Property<Integer> SOCKET_BACKLOG
= Property.integer("socket-backlog", 0);
/**
* Socket keep-alive. See {@link java.net.StandardSocketOptions#SO_KEEPALIVE}
*/
public static final Property<Boolean> SOCKET_KEEPALIVE
= Property.bool("socket-keepalive", false);
/**
* Socket send buffer size. See {@link java.net.StandardSocketOptions#SO_SNDBUF}
*/
public static final Property<Integer> SOCKET_SNDBUF
= Property.integer("socket-sndbuf");
/**
* Socket receive buffer size. See {@link java.net.StandardSocketOptions#SO_RCVBUF}
*/
public static final Property<Integer> SOCKET_RCVBUF
= Property.integer("socket-rcvbuf");
/**
* Socket reuse address. See {@link java.net.StandardSocketOptions#SO_REUSEADDR}
*/
public static final Property<Boolean> SOCKET_REUSEADDR
= Property.bool("socket-reuseaddr", true);
/**
* Socket linger. See {@link java.net.StandardSocketOptions#SO_LINGER}
*/
public static final Property<Integer> SOCKET_LINGER
= Property.integer("socket-linger", -1);
/**
* Socket tcp no-delay. See {@link java.net.StandardSocketOptions#TCP_NODELAY}
*/
public static final Property<Boolean> TCP_NODELAY
= Property.bool("tcp-nodelay", false);
/**
* Read buffer size in bytes. Has no effect on the Netty transport. The NIO2 transport uses this setting as
* fixed-size read buffer for all sessions. The MINA transport uses it as the initial read buffer size, MINA
* requires this to be in the range [64 .. 65536]; if larger, MINA uses 64kB. If not set explicitly on the
* {@link org.apache.sshd.client.SshClient} or {@link org.apache.sshd.server.SshServer}, or if smaller than 64, MINA
* will use its built-in default of 2kB.
*/
public static final Property<Integer> NIO2_READ_BUFFER_SIZE
= Property.validating(Property.integer("nio2-read-buf-size", 32 * 1024),
p -> {
if (p != null) {
ValidateUtils.checkTrue(p > 0, "Read buffer size must be > 0: %d", p);
}
});
/**
* Minimum read buffer size in bytes. Has an effect only on the MINA transport and must be in the range [64..65536].
* If not set, MINA by default uses 64 bytes as minimal read buffer size.
* <p>
* If larger than {@link #NIO2_READ_BUFFER_SIZE}, MINA will use this value also as the initial read buffer size.
*/
public static final Property<Integer> MIN_READ_BUFFER_SIZE
= Property.validating(Property.integer("min-read-buf-size"),
p -> {
if (p != null) {
ValidateUtils.checkTrue(p >= 64 && p <= 64 * 1024,
"Minimum read buffer size must be in the range [64..65536]: %d", p);
}
});
/**
* Maximum allowed size of the initial identification text sent during the handshake
*/
public static final Property<Integer> MAX_IDENTIFICATION_SIZE
= Property.integer("max-identification-size", 16 * 1024);
/**
* Key re-exchange will be automatically performed after the session has sent or received the given amount of bytes.
* If non-positive, then disabled.
*/
public static final Property<Long> REKEY_BYTES_LIMIT
= Property.long_("rekey-bytes-limit", 1024L * 1024L * 1024L); // 1GB
/**
* Key re-exchange will be automatically performed after the specified amount of time has elapsed since the last key
* exchange - in milliseconds. If non-positive then disabled.
*
* @see <A HREF="https://tools.ietf.org/html/rfc4253#section-9">RFC4253 section 9</A>
*/
public static final Property<Duration> REKEY_TIME_LIMIT
= Property.duration("rekey-time-limit", Duration.ofHours(1));
/**
* Key re-exchange will be automatically performed after the specified number of packets has been exchanged -
* positive 64-bit value. If non-positive then disabled.
*
* @see <A HREF="https://tools.ietf.org/html/rfc4344#section-3.1">RFC4344 section 3.1</A>
*/
public static final Property<Long> REKEY_PACKETS_LIMIT
= Property.long_("rekey-packets-limit", 1L << 31);
/**
* Key re-exchange will be automatically performed after the specified number of cipher blocks has been processed -
* positive 64-bit value. If non-positive then disabled. The default is calculated according to
* <A HREF="https://tools.ietf.org/html/rfc4344#section-3.2">RFC4344 section 3.2</A>
*/
public static final Property<Long> REKEY_BLOCKS_LIMIT
= Property.long_("rekey-blocks-limit", 0L);
/**
* Average number of packets to be skipped before an {@code SSH_MSG_IGNORE} message is inserted in the stream. If
* non-positive, then feature is disabled
*
* @see #IGNORE_MESSAGE_VARIANCE
* @see <A HREF="https://tools.ietf.org/html/rfc4251#section-9.3.1">RFC4251 section 9.3.1</A>
*/
public static final Property<Long> IGNORE_MESSAGE_FREQUENCY
= Property.long_("ignore-message-frequency", 1024L);
/**
* The variance to be used around the configured {@link #IGNORE_MESSAGE_FREQUENCY} value in order to avoid insertion
* at a set frequency. If zero, then <U>exact</U> frequency is used. If negative, then the <U>absolute</U> value is
* used. If greater or equal to the frequency, then assumed to be zero - i.e., no variance
*
* @see <A HREF="https://tools.ietf.org/html/rfc4251#section-9.3.1">RFC4251 section 9.3.1</A>
*/
public static final Property<Integer> IGNORE_MESSAGE_VARIANCE
= Property.integer("ignore-message-variance", 32);
/**
* Minimum size of {@code SSH_MSG_IGNORE} payload to send if feature enabled. If non-positive then no message is
* sent. Otherwise, the actual size is between this size and twice its value
*
* @see <A HREF="https://tools.ietf.org/html/rfc4251#section-9.3.1">RFC4251 section 9.3.1</A>
*/
public static final Property<Integer> IGNORE_MESSAGE_SIZE
= Property.integer("ignore-message-size", 16);
/**
* The request type of agent forwarding. The value may be {@value #AGENT_FORWARDING_TYPE_IETF} or
* {@value #AGENT_FORWARDING_TYPE_OPENSSH}.
*/
public static final String AGENT_FORWARDING_TYPE = "agent-fw-auth-type";
/**
* The agent forwarding type defined by IETF (https://tools.ietf.org/html/draft-ietf-secsh-agent-02).
*/
public static final String AGENT_FORWARDING_TYPE_IETF = "auth-agent-req";
/**
* The agent forwarding type defined by OpenSSH.
*/
public static final String AGENT_FORWARDING_TYPE_OPENSSH = "auth-agent-req@openssh.com";
/**
* Configure max. wait time (millis) to wait for space to become available
*/
public static final Property<Duration> WAIT_FOR_SPACE_TIMEOUT
= Property.duration("channel-output-wait-for-space-timeout", Duration.ofSeconds(30L));
/**
* Used to configure the timeout (milliseconds) for receiving a response for the forwarding request
*/
public static final Property<Duration> FORWARD_REQUEST_TIMEOUT
= Property.duration("tcpip-forward-request-timeout", Duration.ofSeconds(15L));
/**
* Property that can be used to configure max. allowed concurrent active channels
*
* @see org.apache.sshd.common.session.ConnectionService#registerChannel(Channel)
*/
public static final Property<Integer> MAX_CONCURRENT_CHANNELS
= Property.integer("max-sshd-channels", Integer.MAX_VALUE);
/**
* RFC4254 does not clearly specify how to handle {@code SSH_MSG_CHANNEL_DATA} and
* {@code SSH_MSG_CHANNEL_EXTENDED_DATA} received through an unknown channel. Therefore, we provide a configurable
* approach to it with the default set to ignore it.
*/
public static final Property<Boolean> SEND_REPLY_FOR_CHANNEL_DATA
= Property.bool("send-unknown-channel-data-reply", false);
/**
* Key used to retrieve the value in the configuration properties map of the maximum number of failed authentication
* requests before the server closes the connection.
*/
public static final Property<Integer> MAX_AUTH_REQUESTS
= Property.integer("max-auth-requests", 20);
/**
* Key used to retrieve the value of welcome banner that will be displayed when a user connects to the server. If
* {@code null}/empty then no banner will be sent. The value can be one of the following:
* <UL>
* <P>
* <LI>A {@link java.io.File} or {@link java.nio.file.Path}, in which case its contents will be transmitted.
* <B>Note:</B> if the file is empty or does not exits, no banner will be transmitted.</LI>
* </P>
*
* <P>
* <LI>A {@link java.net.URI} or a string starting with "file:/", in which case it will be converted to a
* {@link java.nio.file.Path} and handled accordingly.</LI>
* </P>
*
* <P>
* <LI>A string containing a special value indicator - e.g., {@link #AUTO_WELCOME_BANNER_VALUE}, in which case the
* relevant banner content will be generated.</LI>
* </P>
*
* <P>
* <LI>Any other object whose {@code toString()} value yields a non empty string will be used as the banner
* contents.</LI>
* </P>
* </UL>
*
* @see <A HREF="https://tools.ietf.org/html/rfc4252#section-5.4">RFC-4252 section 5.4</A>
*/
public static final Property<Object> WELCOME_BANNER
= Property.object("welcome-banner");
/**
* Special value that can be set for the {@link #WELCOME_BANNER} property indicating that the server should generate
* a banner consisting of the random art of the server's keys (if any are provided). If no server keys are
* available, then no banner will be sent
*/
public static final String AUTO_WELCOME_BANNER_VALUE = "#auto-welcome-banner";
/**
* Key used to denote the language code for the welcome banner (if such a banner is configured).
*/
public static final Property<String> WELCOME_BANNER_LANGUAGE
= Property.string("welcome-banner-language", "en");
/**
* The {@link WelcomeBannerPhase} value - either as an enum or a string
*/
public static final Property<WelcomeBannerPhase> WELCOME_BANNER_PHASE
= Property.enum_("welcome-banner-phase", WelcomeBannerPhase.class, WelcomeBannerPhase.IMMEDIATE);
/**
* The charset to use if the configured welcome banner points to a file - if not specified (either as a string or a
* {@link java.nio.charset.Charset} then the local default is used.
*/
public static final Property<Charset> WELCOME_BANNER_CHARSET
= Property.charset("welcome-banner-charset", Charset.defaultCharset());
/**
* This key is used when configuring multi-step authentications. The value needs to be a blank separated list of
* comma separated list of authentication method names. For example, an argument of
* <code>publickey,password publickey,keyboard-interactive</code> would require the user to complete public key
* authentication, followed by either password or keyboard interactive authentication. Only methods that are next in
* one or more lists are offered at each stage, so for this example, it would not be possible to attempt password or
* keyboard-interactive authentication before public key.
*/
public static final Property<String> AUTH_METHODS
= Property.string("auth-methods");
/**
* Key used to retrieve the value of the maximum concurrent open session count per username. If not set, then
* unlimited
*/
public static final Property<Integer> MAX_CONCURRENT_SESSIONS
= Property.integer("max-concurrent-sessions");
/**
* Key used to retrieve any extra lines to be sent during initial protocol handshake <U>before</U> the
* identification. The configured string value should use {@value #SERVER_EXTRA_IDENT_LINES_SEPARATOR} character to
* denote line breaks
*/
public static final Property<String> SERVER_EXTRA_IDENTIFICATION_LINES
= Property.string("server-extra-identification-lines");
/**
* Separator used in the {@link #SERVER_EXTRA_IDENTIFICATION_LINES} configuration string to indicate new line break
*/
public static final char SERVER_EXTRA_IDENT_LINES_SEPARATOR = '|';
/**
* Key used to retrieve the value of the server identification string. If set, then it is <U>appended</U> to the
* (standard) "SSH-2.0-" prefix. Otherwise a default is sent that consists of "SSH-2.0-" plus
* the current SSHD artifact name and version in uppercase - e.g., "SSH-2.0-APACHE-SSHD-1.0.0"
*/
public static final Property<String> SERVER_IDENTIFICATION
= Property.string("server-identification");
/**
* Key used to configure the timeout used when receiving a close request on a channel to wait until the command
* cleanly exits after setting an EOF on the input stream.
*/
public static final Property<Duration> COMMAND_EXIT_TIMEOUT
= Property.duration("command-exit-timeout", Duration.ofMillis(5L));
/**
* A URL pointing to the moduli file. If not specified, the default internal file will be used.
*/
public static final Property<String> MODULI_URL
= Property.string("moduli-url");
/**
* See {@link org.apache.sshd.server.auth.keyboard.DefaultKeyboardInteractiveAuthenticator}.
*/
public static final Property<String> KB_SERVER_INTERACTIVE_NAME
= Property.string("kb-server-interactive-name", "Password authentication");
/**
* See {@link org.apache.sshd.server.auth.keyboard.DefaultKeyboardInteractiveAuthenticator}.
*/
public static final Property<String> KB_SERVER_INTERACTIVE_INSTRUCTION
= Property.string("kb-server-interactive-instruction", "");
/**
* See {@link org.apache.sshd.server.auth.keyboard.DefaultKeyboardInteractiveAuthenticator}.
*/
public static final Property<String> KB_SERVER_INTERACTIVE_LANG
= Property.string("kb-server-interactive-language", "en-US");
/**
* See {@link org.apache.sshd.server.auth.keyboard.DefaultKeyboardInteractiveAuthenticator}.
*/
public static final Property<String> KB_SERVER_INTERACTIVE_PROMPT
= Property.string("kb-server-interactive-prompt", "Password: ");
/**
* See {@link org.apache.sshd.server.auth.keyboard.DefaultKeyboardInteractiveAuthenticator}.
*/
public static final Property<Boolean> KB_SERVER_INTERACTIVE_ECHO_PROMPT
= Property.bool("kb-server-interactive-echo-prompt", false);
/**
* Maximum amount of extended (a.k.a. STDERR) data allowed to be accumulated until a {@link ChannelDataReceiver} for
* the data is registered
*/
public static final Property<Integer> MAX_EXTDATA_BUFSIZE
= Property.integer("channel-session-max-extdata-bufsize", 0);
/**
* See {@link org.apache.sshd.server.kex.DHGEXServer}.
*/
public static final Property<Integer> PROP_DHGEX_SERVER_MIN_KEY
= Property.integer("dhgex-server-min");
/**
* See {@link org.apache.sshd.server.kex.DHGEXServer}.
*/
public static final Property<Integer> PROP_DHGEX_SERVER_MAX_KEY
= Property.integer("dhgex-server-max");
/**
* Value used by the {@link org.apache.sshd.server.shell.InvertedShellWrapper} to control the "busy-wait"
* sleep time (millis) on the pumping loop if nothing was pumped - must be <U>positive</U>.
*/
public static final Property<Duration> PUMP_SLEEP_TIME
= Property.duration("inverted-shell-wrapper-pump-sleep", Duration.ofMillis(1));
/**
* Value used by the {@link org.apache.sshd.server.shell.InvertedShellWrapper} to control copy buffer size.
*/
public static final Property<Integer> BUFFER_SIZE
= Property.integer("inverted-shell-wrapper-buffer-size", IoUtils.DEFAULT_COPY_SIZE);
/**
* Configuration value for the {@link org.apache.sshd.server.x11.X11ForwardSupport} to control the channel open
* timeout.
*/
public static final Property<Duration> X11_OPEN_TIMEOUT
= Property.duration("x11-fwd-open-timeout", Duration.ofSeconds(30L));
/**
* Configuration value for the {@link org.apache.sshd.server.x11.X11ForwardSupport} to control from which X11
* display number to start looking for a free value.
*/
public static final Property<Integer> X11_DISPLAY_OFFSET
= Property.integer("x11-fwd-display-offset", 10);
/**
* Configuration value for the {@link org.apache.sshd.server.x11.X11ForwardSupport} to control up to which (but not
* including) X11 display number to look or a free value.
*/
public static final Property<Integer> X11_MAX_DISPLAYS
= Property.integer("x11-fwd-max-display", 1000);
/**
* Configuration value for the {@link org.apache.sshd.server.x11.X11ForwardSupport} to control the base port number
* for the X11 display number socket binding.
*/
public static final Property<Integer> X11_BASE_PORT
= Property.integer("x11-fwd-base-port", 6000);
/**
* Configuration value for the {@link org.apache.sshd.server.x11.X11ForwardSupport} to control the host used to bind
* to for the X11 display when looking for a free port.
*/
public static final Property<String> X11_BIND_HOST
= Property.string("x11-fwd-bind-host", SshdSocketAddress.LOCALHOST_IPV4);
/**
* Configuration value for the maximum number of proxy jumps to allow in an SSH connection; by default 10. If there
* are more proxy jumps for an SSH connection, chances are that the proxy chain has a loop.
*/
public static final Property<Integer> MAX_PROXY_JUMPS = Property.validating(Property.integer("max-proxy-jumps", 10), p -> {
if (p != null) {
ValidateUtils.checkTrue(p.intValue() > 0, "Maximum number of proxy jumps allowed must be greater than zero, is %d",
p);
}
});
private CoreModuleProperties() {
throw new UnsupportedOperationException("No instance");
}
}
|
googleapis/google-cloud-java | 36,368 | java-aiplatform/proto-google-cloud-aiplatform-v1/src/main/java/com/google/cloud/aiplatform/v1/UpdateDatasetVersionRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/aiplatform/v1/dataset_service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.aiplatform.v1;
/**
*
*
* <pre>
* Request message for
* [DatasetService.UpdateDatasetVersion][google.cloud.aiplatform.v1.DatasetService.UpdateDatasetVersion].
* </pre>
*
* Protobuf type {@code google.cloud.aiplatform.v1.UpdateDatasetVersionRequest}
*/
public final class UpdateDatasetVersionRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.aiplatform.v1.UpdateDatasetVersionRequest)
UpdateDatasetVersionRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use UpdateDatasetVersionRequest.newBuilder() to construct.
private UpdateDatasetVersionRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private UpdateDatasetVersionRequest() {}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new UpdateDatasetVersionRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.aiplatform.v1.DatasetServiceProto
.internal_static_google_cloud_aiplatform_v1_UpdateDatasetVersionRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.aiplatform.v1.DatasetServiceProto
.internal_static_google_cloud_aiplatform_v1_UpdateDatasetVersionRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest.class,
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest.Builder.class);
}
private int bitField0_;
public static final int DATASET_VERSION_FIELD_NUMBER = 1;
private com.google.cloud.aiplatform.v1.DatasetVersion datasetVersion_;
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the datasetVersion field is set.
*/
@java.lang.Override
public boolean hasDatasetVersion() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The datasetVersion.
*/
@java.lang.Override
public com.google.cloud.aiplatform.v1.DatasetVersion getDatasetVersion() {
return datasetVersion_ == null
? com.google.cloud.aiplatform.v1.DatasetVersion.getDefaultInstance()
: datasetVersion_;
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.cloud.aiplatform.v1.DatasetVersionOrBuilder getDatasetVersionOrBuilder() {
return datasetVersion_ == null
? com.google.cloud.aiplatform.v1.DatasetVersion.getDefaultInstance()
: datasetVersion_;
}
public static final int UPDATE_MASK_FIELD_NUMBER = 2;
private com.google.protobuf.FieldMask updateMask_;
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
@java.lang.Override
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
@java.lang.Override
public com.google.protobuf.FieldMask getUpdateMask() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
@java.lang.Override
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_;
}
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)) {
output.writeMessage(1, getDatasetVersion());
}
if (((bitField0_ & 0x00000002) != 0)) {
output.writeMessage(2, getUpdateMask());
}
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.CodedOutputStream.computeMessageSize(1, getDatasetVersion());
}
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask());
}
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.aiplatform.v1.UpdateDatasetVersionRequest)) {
return super.equals(obj);
}
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest other =
(com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest) obj;
if (hasDatasetVersion() != other.hasDatasetVersion()) return false;
if (hasDatasetVersion()) {
if (!getDatasetVersion().equals(other.getDatasetVersion())) return false;
}
if (hasUpdateMask() != other.hasUpdateMask()) return false;
if (hasUpdateMask()) {
if (!getUpdateMask().equals(other.getUpdateMask())) 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 (hasDatasetVersion()) {
hash = (37 * hash) + DATASET_VERSION_FIELD_NUMBER;
hash = (53 * hash) + getDatasetVersion().hashCode();
}
if (hasUpdateMask()) {
hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER;
hash = (53 * hash) + getUpdateMask().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest 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.aiplatform.v1.UpdateDatasetVersionRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest 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.aiplatform.v1.UpdateDatasetVersionRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest 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.aiplatform.v1.UpdateDatasetVersionRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest 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.aiplatform.v1.UpdateDatasetVersionRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest 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.aiplatform.v1.UpdateDatasetVersionRequest 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;
}
/**
*
*
* <pre>
* Request message for
* [DatasetService.UpdateDatasetVersion][google.cloud.aiplatform.v1.DatasetService.UpdateDatasetVersion].
* </pre>
*
* Protobuf type {@code google.cloud.aiplatform.v1.UpdateDatasetVersionRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.aiplatform.v1.UpdateDatasetVersionRequest)
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.aiplatform.v1.DatasetServiceProto
.internal_static_google_cloud_aiplatform_v1_UpdateDatasetVersionRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.aiplatform.v1.DatasetServiceProto
.internal_static_google_cloud_aiplatform_v1_UpdateDatasetVersionRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest.class,
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest.Builder.class);
}
// Construct using com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
getDatasetVersionFieldBuilder();
getUpdateMaskFieldBuilder();
}
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
datasetVersion_ = null;
if (datasetVersionBuilder_ != null) {
datasetVersionBuilder_.dispose();
datasetVersionBuilder_ = null;
}
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.aiplatform.v1.DatasetServiceProto
.internal_static_google_cloud_aiplatform_v1_UpdateDatasetVersionRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest getDefaultInstanceForType() {
return com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest build() {
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest buildPartial() {
com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest result =
new com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.datasetVersion_ =
datasetVersionBuilder_ == null ? datasetVersion_ : datasetVersionBuilder_.build();
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build();
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.aiplatform.v1.UpdateDatasetVersionRequest) {
return mergeFrom((com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest other) {
if (other == com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest.getDefaultInstance())
return this;
if (other.hasDatasetVersion()) {
mergeDatasetVersion(other.getDatasetVersion());
}
if (other.hasUpdateMask()) {
mergeUpdateMask(other.getUpdateMask());
}
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 10:
{
input.readMessage(getDatasetVersionFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry);
bitField0_ |= 0x00000002;
break;
} // case 18
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 com.google.cloud.aiplatform.v1.DatasetVersion datasetVersion_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.aiplatform.v1.DatasetVersion,
com.google.cloud.aiplatform.v1.DatasetVersion.Builder,
com.google.cloud.aiplatform.v1.DatasetVersionOrBuilder>
datasetVersionBuilder_;
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the datasetVersion field is set.
*/
public boolean hasDatasetVersion() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The datasetVersion.
*/
public com.google.cloud.aiplatform.v1.DatasetVersion getDatasetVersion() {
if (datasetVersionBuilder_ == null) {
return datasetVersion_ == null
? com.google.cloud.aiplatform.v1.DatasetVersion.getDefaultInstance()
: datasetVersion_;
} else {
return datasetVersionBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setDatasetVersion(com.google.cloud.aiplatform.v1.DatasetVersion value) {
if (datasetVersionBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
datasetVersion_ = value;
} else {
datasetVersionBuilder_.setMessage(value);
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setDatasetVersion(
com.google.cloud.aiplatform.v1.DatasetVersion.Builder builderForValue) {
if (datasetVersionBuilder_ == null) {
datasetVersion_ = builderForValue.build();
} else {
datasetVersionBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeDatasetVersion(com.google.cloud.aiplatform.v1.DatasetVersion value) {
if (datasetVersionBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)
&& datasetVersion_ != null
&& datasetVersion_
!= com.google.cloud.aiplatform.v1.DatasetVersion.getDefaultInstance()) {
getDatasetVersionBuilder().mergeFrom(value);
} else {
datasetVersion_ = value;
}
} else {
datasetVersionBuilder_.mergeFrom(value);
}
if (datasetVersion_ != null) {
bitField0_ |= 0x00000001;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearDatasetVersion() {
bitField0_ = (bitField0_ & ~0x00000001);
datasetVersion_ = null;
if (datasetVersionBuilder_ != null) {
datasetVersionBuilder_.dispose();
datasetVersionBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.aiplatform.v1.DatasetVersion.Builder getDatasetVersionBuilder() {
bitField0_ |= 0x00000001;
onChanged();
return getDatasetVersionFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.cloud.aiplatform.v1.DatasetVersionOrBuilder getDatasetVersionOrBuilder() {
if (datasetVersionBuilder_ != null) {
return datasetVersionBuilder_.getMessageOrBuilder();
} else {
return datasetVersion_ == null
? com.google.cloud.aiplatform.v1.DatasetVersion.getDefaultInstance()
: datasetVersion_;
}
}
/**
*
*
* <pre>
* Required. The DatasetVersion which replaces the resource on the server.
* </pre>
*
* <code>
* .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 1 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.aiplatform.v1.DatasetVersion,
com.google.cloud.aiplatform.v1.DatasetVersion.Builder,
com.google.cloud.aiplatform.v1.DatasetVersionOrBuilder>
getDatasetVersionFieldBuilder() {
if (datasetVersionBuilder_ == null) {
datasetVersionBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.cloud.aiplatform.v1.DatasetVersion,
com.google.cloud.aiplatform.v1.DatasetVersion.Builder,
com.google.cloud.aiplatform.v1.DatasetVersionOrBuilder>(
getDatasetVersion(), getParentForChildren(), isClean());
datasetVersion_ = null;
}
return datasetVersionBuilder_;
}
private com.google.protobuf.FieldMask updateMask_;
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
updateMaskBuilder_;
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return Whether the updateMask field is set.
*/
public boolean hasUpdateMask() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*
* @return The updateMask.
*/
public com.google.protobuf.FieldMask getUpdateMask() {
if (updateMaskBuilder_ == null) {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
} else {
return updateMaskBuilder_.getMessage();
}
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
updateMask_ = value;
} else {
updateMaskBuilder_.setMessage(value);
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) {
if (updateMaskBuilder_ == null) {
updateMask_ = builderForValue.build();
} else {
updateMaskBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) {
if (updateMaskBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)
&& updateMask_ != null
&& updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) {
getUpdateMaskBuilder().mergeFrom(value);
} else {
updateMask_ = value;
}
} else {
updateMaskBuilder_.mergeFrom(value);
}
if (updateMask_ != null) {
bitField0_ |= 0x00000002;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public Builder clearUpdateMask() {
bitField0_ = (bitField0_ & ~0x00000002);
updateMask_ = null;
if (updateMaskBuilder_ != null) {
updateMaskBuilder_.dispose();
updateMaskBuilder_ = null;
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() {
bitField0_ |= 0x00000002;
onChanged();
return getUpdateMaskFieldBuilder().getBuilder();
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() {
if (updateMaskBuilder_ != null) {
return updateMaskBuilder_.getMessageOrBuilder();
} else {
return updateMask_ == null
? com.google.protobuf.FieldMask.getDefaultInstance()
: updateMask_;
}
}
/**
*
*
* <pre>
* Required. The update mask applies to the resource.
* For the `FieldMask` definition, see
* [google.protobuf.FieldMask][google.protobuf.FieldMask]. Updatable fields:
*
* * `display_name`
* </pre>
*
* <code>.google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED];
* </code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>
getUpdateMaskFieldBuilder() {
if (updateMaskBuilder_ == null) {
updateMaskBuilder_ =
new com.google.protobuf.SingleFieldBuilderV3<
com.google.protobuf.FieldMask,
com.google.protobuf.FieldMask.Builder,
com.google.protobuf.FieldMaskOrBuilder>(
getUpdateMask(), getParentForChildren(), isClean());
updateMask_ = null;
}
return updateMaskBuilder_;
}
@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.aiplatform.v1.UpdateDatasetVersionRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.aiplatform.v1.UpdateDatasetVersionRequest)
private static final com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest();
}
public static com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<UpdateDatasetVersionRequest> PARSER =
new com.google.protobuf.AbstractParser<UpdateDatasetVersionRequest>() {
@java.lang.Override
public UpdateDatasetVersionRequest 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<UpdateDatasetVersionRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<UpdateDatasetVersionRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.aiplatform.v1.UpdateDatasetVersionRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/shindig | 36,534 | java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/GadgetsHandlerServiceTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.shindig.gadgets.servlet;
import static org.easymock.EasyMock.capture;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.apache.shindig.auth.SecurityToken;
import org.apache.shindig.auth.SecurityTokenCodec;
import org.apache.shindig.auth.SecurityTokenException;
import org.apache.shindig.common.EasyMockTestCase;
import org.apache.shindig.common.servlet.HttpUtil;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.common.util.FakeTimeSource;
import org.apache.shindig.config.ContainerConfig;
import org.apache.shindig.gadgets.Gadget;
import org.apache.shindig.gadgets.GadgetContext;
import org.apache.shindig.gadgets.GadgetException;
import org.apache.shindig.gadgets.GadgetException.Code;
import org.apache.shindig.gadgets.RenderingContext;
import org.apache.shindig.gadgets.admin.GadgetAdminStore;
import org.apache.shindig.gadgets.features.ApiDirective;
import org.apache.shindig.gadgets.features.FeatureRegistry;
import org.apache.shindig.gadgets.features.FeatureRegistry.FeatureBundle;
import org.apache.shindig.gadgets.features.FeatureRegistryProvider;
import org.apache.shindig.gadgets.http.HttpResponse;
import org.apache.shindig.gadgets.http.HttpResponseBuilder;
import org.apache.shindig.gadgets.js.JsException;
import org.apache.shindig.gadgets.js.JsRequest;
import org.apache.shindig.gadgets.js.JsRequestBuilder;
import org.apache.shindig.gadgets.js.JsResponseBuilder;
import org.apache.shindig.gadgets.js.JsServingPipeline;
import org.apache.shindig.gadgets.process.ProcessingException;
import org.apache.shindig.gadgets.servlet.GadgetsHandlerApi.Feature;
import org.apache.shindig.gadgets.uri.DefaultIframeUriManager;
import org.apache.shindig.gadgets.uri.JsUriManager;
import org.apache.shindig.gadgets.uri.JsUriManager.JsUri;
import org.apache.shindig.gadgets.uri.ProxyUriManager;
import org.apache.shindig.gadgets.uri.ProxyUriManager.ProxyUri;
import org.apache.shindig.protocol.conversion.BeanDelegator;
import org.apache.shindig.protocol.conversion.BeanFilter;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
public class GadgetsHandlerServiceTest extends EasyMockTestCase {
private static final String TOKEN = "<token data>";
private static final String OWNER = "<owner>";
private static final String VIEWER = "<viewer>";
private static final String CONTAINER = "container";
private static final Long CURRENT_TIME_MS = 123L;
private static final Long SPEC_REFRESH_INTERVAL_MS = 456L;
private static final Long METADATA_EXPIRY_TIME_MS = CURRENT_TIME_MS + SPEC_REFRESH_INTERVAL_MS;
private static final Long TOKEN_EXPIRY_TIME_MS = CURRENT_TIME_MS + 789L;
private static final Uri RESOURCE = Uri.parse("http://example.com/data");
private static final String FALLBACK = "http://example.com/data2";
private static final String RPC_SERVICE_1 = "rcp_service_1";
private static final String RPC_SERVICE_2 = "rpc_service_2";
private static final String RPC_SERVICE_3 = "rpc_service_3";
private final BeanDelegator delegator = new BeanDelegator(GadgetsHandlerService.API_CLASSES,
GadgetsHandlerService.ENUM_CONVERSION_MAP);
private final FakeTimeSource timeSource = new FakeTimeSource(CURRENT_TIME_MS);
private final FeatureRegistry mockRegistry = mock(FeatureRegistry.class);
private final FakeProcessor processor = new FakeProcessor(mockRegistry);
private final FakeIframeUriManager urlGenerator = new FakeIframeUriManager();
private final ProxyUriManager proxyUriManager = mock(ProxyUriManager.class);
private final JsUriManager jsUriManager = mock(JsUriManager.class);
private final ProxyHandler proxyHandler = mock(ProxyHandler.class);
private final CajaContentRewriter cajaContentRewriter = mock(CajaContentRewriter.class);
private final JsServingPipeline jsPipeline = mock(JsServingPipeline.class);
private final JsRequestBuilder jsRequestBuilder = new JsRequestBuilder(jsUriManager, null);
private final GadgetAdminStore gadgetAdminStore = mock(GadgetAdminStore.class);
private ContainerConfig config;
private FakeSecurityTokenCodec tokenCodec;
private GadgetsHandlerService gadgetHandler;
private GadgetsHandlerService gadgetHandlerWithAdmin;
private FeatureRegistryProvider featureRegistryProvider;
@Before
public void setUp() {
tokenCodec = new FakeSecurityTokenCodec();
featureRegistryProvider = new FeatureRegistryProvider() {
public FeatureRegistry get(String repository) throws GadgetException {
return mockRegistry;
}
};
config = createMock(ContainerConfig.class);
gadgetHandler = new GadgetsHandlerService(timeSource, processor, urlGenerator, tokenCodec,
proxyUriManager, jsUriManager, proxyHandler, jsPipeline, jsRequestBuilder,
SPEC_REFRESH_INTERVAL_MS, new BeanFilter(), cajaContentRewriter, gadgetAdminStore,
featureRegistryProvider, new ModuleIdManagerImpl(),config);
gadgetHandlerWithAdmin = new GadgetsHandlerService(timeSource, processor, urlGenerator,
tokenCodec, proxyUriManager, jsUriManager, proxyHandler, jsPipeline, jsRequestBuilder,
SPEC_REFRESH_INTERVAL_MS, new BeanFilter(), cajaContentRewriter, gadgetAdminStore,
featureRegistryProvider, new ModuleIdManagerImpl(),config);
}
// Next test verify that the API data classes are configured correctly.
// The mapping is done using reflection in runtime, so this test verify mapping is complete
// this test will prevent from not intended change to the API.
// DO NOT REMOVE TEST
@Test
public void testHandlerDataDelegation() throws Exception {
delegator.validate();
}
private void setupMockGadgetAdminStore(boolean isAllowed) {
EasyMock.expect(gadgetAdminStore.checkFeatureAdminInfo(EasyMock.isA(Gadget.class)))
.andReturn(isAllowed).anyTimes();
EasyMock.expect(gadgetAdminStore.getAdditionalRpcServiceIds(EasyMock.isA(Gadget.class)))
.andReturn(Sets.newHashSet(RPC_SERVICE_3));
}
@SuppressWarnings("unchecked")
private void setupMockRegistry(List<String> features) {
EasyMock.expect(mockRegistry.getFeatures(EasyMock.isA(Collection.class)))
.andReturn(Lists.newArrayList(features)).anyTimes();
FeatureBundle featureBundle = createMockFeatureBundle();
FeatureRegistry.LookupResult lr = createMockLookupResult(ImmutableList.of(featureBundle));
EasyMock.expect(
mockRegistry.getFeatureResources(isA(GadgetContext.class),
eq(Lists.newArrayList(features)), EasyMock.<List<String>> isNull()))
.andReturn(lr).anyTimes();
replay();
}
private FeatureBundle createMockFeatureBundle() {
FeatureBundle result = createMock(FeatureBundle.class);
expect(result.getApis(ApiDirective.Type.RPC, false)).andReturn(
Lists.newArrayList(RPC_SERVICE_1, RPC_SERVICE_2)).anyTimes();
replay(result);
return result;
}
private FeatureRegistry.LookupResult createMockLookupResult(List<FeatureBundle> featureBundles) {
FeatureRegistry.LookupResult result = createMock(FeatureRegistry.LookupResult.class);
EasyMock.expect(result.getBundles()).andReturn(featureBundles).anyTimes();
replay(result);
return result;
}
@Test
public void testGetMetadata() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL,
CONTAINER, "default", createAuthContext(null, null), ImmutableList.of("*"));
setupMockGadgetAdminStore(true);
setupMockRegistry(ImmutableList.<String> of("auth-refresh"));
GadgetsHandlerApi.MetadataResponse response = gadgetHandler.getMetadata(request);
assertEquals(FakeIframeUriManager.IFRAME_URIS_STRINGS, response.getIframeUrls());
assertTrue(response.getNeedsTokenRefresh());
assertEquals(1, response.getViews().size());
assertEquals(FakeProcessor.SPEC_TITLE, response.getModulePrefs().getTitle());
assertEquals(FakeProcessor.LINK_HREF,
response.getModulePrefs().getLinks().get(FakeProcessor.LINK_REL).getHref().toString());
assertEquals(FakeProcessor.LINK_REL,
response.getModulePrefs().getLinks().get(FakeProcessor.LINK_REL).getRel());
assertEquals(1, response.getUserPrefs().size());
assertEquals("up_one", response.getUserPrefs().get("up_one").getDisplayName());
assertEquals(4, response.getUserPrefs().get("up_one").getOrderedEnumValues().size());
assertEquals(CURRENT_TIME_MS, response.getResponseTimeMs());
assertEquals(METADATA_EXPIRY_TIME_MS, response.getExpireTimeMs());
assertEquals(Sets.newHashSet(RPC_SERVICE_1, RPC_SERVICE_2, RPC_SERVICE_3), response.getRpcServiceIds());
verify();
}
@Test
public void testGetMetadataWithalwaysAppendST() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL,
CONTAINER, "default", createAuthContext(null, null), ImmutableList.of("*"));
setupMockGadgetAdminStore(true);
setupMockRegistry(ImmutableList.<String> of(""));
expect(config.getBool(CONTAINER, DefaultIframeUriManager.SECURITY_TOKEN_ALWAYS_KEY)).andReturn(
true).once();
replay(config);
GadgetsHandlerApi.MetadataResponse response = gadgetHandler.getMetadata(request);
assertTrue(response.getNeedsTokenRefresh());
verify();
}
@Test
public void testFeatureAdminAllowedGadget() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL4,
CONTAINER, "default", createAuthContext(null, null), ImmutableList.of("*"));
setupMockGadgetAdminStore(true);
setupMockRegistry(Lists.newArrayList("example-feature", "example-feature2"));
GadgetsHandlerApi.MetadataResponse response = gadgetHandlerWithAdmin.getMetadata(request);
assertEquals(FakeIframeUriManager.IFRAME_URIS_STRINGS, response.getIframeUrls());
assertEquals(1, response.getViews().size());
assertEquals(FakeProcessor.SPEC_TITLE, response.getModulePrefs().getTitle());
assertEquals(FakeProcessor.LINK_HREF,
response.getModulePrefs().getLinks().get(FakeProcessor.LINK_REL).getHref().toString());
assertEquals(FakeProcessor.LINK_REL,
response.getModulePrefs().getLinks().get(FakeProcessor.LINK_REL).getRel());
assertEquals(1, response.getUserPrefs().size());
assertEquals("up_one", response.getUserPrefs().get("up_one").getDisplayName());
assertEquals(4, response.getUserPrefs().get("up_one").getOrderedEnumValues().size());
assertEquals(CURRENT_TIME_MS, response.getResponseTimeMs());
assertEquals(METADATA_EXPIRY_TIME_MS, response.getExpireTimeMs());
assertEquals(Sets.newHashSet(RPC_SERVICE_1, RPC_SERVICE_2, RPC_SERVICE_3), response.getRpcServiceIds());
verify();
}
@Test(expected = ProcessingException.class)
public void testFeatureAdminDeniedGadget() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL4,
CONTAINER, "default", createAuthContext(null, null), ImmutableList.of("*"));
setupMockGadgetAdminStore(false);
setupMockRegistry(Lists.newArrayList("example-feature", "example-feature2"));
gadgetHandlerWithAdmin.getMetadata(request);
}
@Test
public void testGetMetadataOnlyView() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL,
CONTAINER, null, createAuthContext(null, null), ImmutableList.of("views.*"));
setupMockGadgetAdminStore(false);
setupMockRegistry(new ArrayList<String>());
GadgetsHandlerApi.MetadataResponse response = gadgetHandler.getMetadata(request);
assertNull(response.getIframeUrls());
assertNull(response.getUserPrefs());
assertNull(response.getModulePrefs());
assertNull(response.getUrl());
assertEquals(1, response.getViews().size());
verify();
}
@Test(expected = ProcessingException.class)
public void testGetMetadataNoView() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL3,
CONTAINER, "invalid_view", createAuthContext(null, null), ImmutableList.of("*"));
replay();
gadgetHandler.getMetadata(request);
}
@Test(expected = ProcessingException.class)
public void testGetMetadataNoContainer() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL, null,
null, createAuthContext(null, null), ImmutableList.of("*"));
replay();
gadgetHandler.getMetadata(request);
}
@Test(expected = ProcessingException.class)
public void testGetMetadataNoUrl() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(null, CONTAINER, null,
createAuthContext(null, null), ImmutableList.of("*"));
replay();
gadgetHandler.getMetadata(request);
}
@Test(expected = ProcessingException.class)
public void testGetMetadataNoFields() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL,
CONTAINER, null, createAuthContext(null, null), null);
replay();
gadgetHandler.getMetadata(request);
}
@Test(expected = ProcessingException.class)
public void testGetMetadataBadGadget() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(Uri.parse("unknown"),
CONTAINER, null, createAuthContext(null, null), null);
replay();
gadgetHandler.getMetadata(request);
}
@Test
public void testGetMetadataNoToken() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL,
CONTAINER, "default", null, ImmutableList.of("*"));
setupMockGadgetAdminStore(true);
setupMockRegistry(Lists.newArrayList("auth-refresh"));
GadgetsHandlerApi.MetadataResponse response = gadgetHandler.getMetadata(request);
assertEquals(FakeIframeUriManager.IFRAME_URIS_STRINGS, response.getIframeUrls());
verify();
}
@Test
public void testGetMetadataWithParams() throws Exception {
GadgetsHandlerApi.MetadataRequest request = createMetadataRequest(FakeProcessor.SPEC_URL4,
CONTAINER, "default", createAuthContext(null, null), ImmutableList.of("*"));
setupMockGadgetAdminStore(true);
setupMockRegistry(Lists.newArrayList("auth-refresh"));
GadgetsHandlerApi.MetadataResponse response = gadgetHandler.getMetadata(request);
Map<String, Feature> features = response.getModulePrefs().getFeatures();
// make sure that the feature set contains all the features, and no extra features
// Note that the core feature is automatically included.
assertTrue(features.containsKey(FakeProcessor.FEATURE1)
&& features.containsKey(FakeProcessor.FEATURE2)
&& features.containsKey(FakeProcessor.FEATURE3) && features.size() == 3);
Multimap<String, String> params1 = features.get(FakeProcessor.FEATURE2).getParams();
assertEquals(ImmutableList.of(FakeProcessor.PARAM_VALUE, FakeProcessor.PARAM_VALUE2),
params1.get(FakeProcessor.PARAM_NAME));
Multimap<String, String> params2 = features.get(FakeProcessor.FEATURE3).getParams();
assertEquals(ImmutableList.of(FakeProcessor.PARAM_VALUE3),
params2.get(FakeProcessor.PARAM_NAME2));
verify();
}
@Test
public void testGetToken() throws Exception {
GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER,
createAuthContext(OWNER, VIEWER), ImmutableList.of("*"));
replay();
tokenCodec.encodedToken = TOKEN;
GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request);
assertEquals(TOKEN, response.getToken());
assertEquals(CURRENT_TIME_MS, response.getResponseTimeMs());
assertEquals(TOKEN_EXPIRY_TIME_MS, response.getExpireTimeMs());
assertEquals(OWNER, tokenCodec.authContext.getOwnerId());
assertEquals(VIEWER, tokenCodec.authContext.getViewerId());
assertEquals(CONTAINER, tokenCodec.authContext.getContainer());
verify();
}
@Test(expected = ProcessingException.class)
public void testGetTokenNoContainer() throws Exception {
GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, null,
createAuthContext(OWNER, VIEWER), ImmutableList.of("*"));
replay();
gadgetHandler.getToken(request);
}
@Test(expected = ProcessingException.class)
public void testGetTokenNoUrl() throws Exception {
GadgetsHandlerApi.TokenRequest request = createTokenRequest(null, CONTAINER,
createAuthContext(OWNER, VIEWER), ImmutableList.of("*"));
replay();
gadgetHandler.getToken(request);
}
@Test(expected = ProcessingException.class)
public void testGetTokenNoFields() throws Exception {
GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER,
createAuthContext(OWNER, VIEWER), null);
replay();
gadgetHandler.getToken(request);
}
@Test(expected = SecurityTokenException.class)
public void testGetTokenException() throws Exception {
GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER,
createAuthContext(OWNER, VIEWER), ImmutableList.of("*"));
replay();
tokenCodec.exc = new SecurityTokenException("bad data");
gadgetHandler.getToken(request);
}
@Test
public void testGetTokenNoToken() throws Exception {
GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER,
null, ImmutableList.of("*"));
replay();
tokenCodec.encodedToken = TOKEN;
GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request);
assertEquals(TOKEN, response.getToken());
assertNull(CONTAINER, tokenCodec.authContext);
verify();
}
@Test
public void testCreateJsResponse() throws Exception {
Uri jsUri = Uri.parse("http://www.shindig.com/js");
String content = "content";
GadgetsHandlerApi.JsResponse jsResponse = gadgetHandler.createJsResponse(null, jsUri, content,
ImmutableSet.of("*"), null);
BeanDelegator.validateDelegator(jsResponse);
}
@Test
public void testGetJsUri() throws Exception {
List<String> fields = ImmutableList.of("jsurl");
List<String> features = ImmutableList.of("rpc");
Uri resUri = Uri.parse("server.com/gadgets/js/rpc");
GadgetsHandlerApi.JsRequest request = createJsRequest(null, CONTAINER, fields, features, null);
Capture<JsUri> uriCapture = new Capture<JsUri>();
expect(jsUriManager.makeExternJsUri(capture(uriCapture))).andReturn(resUri);
replay();
GadgetsHandlerApi.JsResponse response = gadgetHandler.getJs(request);
JsUri expectedUri = new JsUri(null, false, false, CONTAINER, null, features, null, null, false,
false, RenderingContext.GADGET, null, null);
assertEquals(expectedUri, uriCapture.getValue());
assertEquals(resUri, response.getJsUrl());
assertNull(response.getJsContent());
assertEquals(timeSource.currentTimeMillis() + HttpUtil.getDefaultTtl() * 1000, response
.getExpireTimeMs().longValue());
verify();
}
@Test(expected = ProcessingException.class)
public void testJsNoContainer() throws Exception {
List<String> fields = ImmutableList.of("*");
GadgetsHandlerApi.JsRequest request = createJsRequest(null, null, fields,
ImmutableList.of("rpc"), null);
gadgetHandler.getJs(request);
}
@Test
public void testGetJsData() throws Exception {
List<String> fields = ImmutableList.of("jscontent");
List<String> features = ImmutableList.of("rpc");
Uri resUri = Uri.parse("http://server.com/gadgets/js/rpc");
Capture<JsUri> uriCapture = new Capture<JsUri>();
String jsContent = "var a;";
String onload = "do this";
String repository = "v01";
expect(jsUriManager.makeExternJsUri(capture(uriCapture))).andReturn(resUri);
expect(jsPipeline.execute(EasyMock.isA(JsRequest.class))).andReturn(
new JsResponseBuilder().appendJs(jsContent, "js").setProxyCacheable(true).build());
GadgetsHandlerApi.JsRequest request = createJsRequest(FakeProcessor.SPEC_URL.toString(),
CONTAINER, fields, features, repository);
expect(request.getOnload()).andStubReturn(onload);
expect(request.getContext()).andStubReturn(GadgetsHandlerApi.RenderingContext.CONTAINER);
replay();
GadgetsHandlerApi.JsResponse response = gadgetHandler.getJs(request);
JsUri expectedUri = new JsUri(null, false, false, CONTAINER, FakeProcessor.SPEC_URL.toString(),
features, null, onload, false, false, RenderingContext.CONTAINER, null, repository);
assertEquals(expectedUri, uriCapture.getValue());
assertNull(response.getJsUrl());
assertEquals(jsContent, response.getJsContent());
assertEquals(timeSource.currentTimeMillis() + HttpUtil.getDefaultTtl() * 1000, response
.getExpireTimeMs().longValue());
verify();
}
@Test(expected = ProcessingException.class)
public void testGetJsDataWithException() throws Exception {
List<String> fields = ImmutableList.of("jscontent");
List<String> features = ImmutableList.of("unknown");
Uri resUri = Uri.parse("http://server.com/gadgets/js/foo");
Capture<JsUri> uriCapture = new Capture<JsUri>();
expect(jsUriManager.makeExternJsUri(capture(uriCapture))).andReturn(resUri);
expect(jsPipeline.execute(EasyMock.isA(JsRequest.class))).andThrow(
new JsException(404, "error"));
GadgetsHandlerApi.JsRequest request = createJsRequest(FakeProcessor.SPEC_URL.toString(),
CONTAINER, fields, features, null);
expect(request.getOnload()).andStubReturn("do this");
expect(request.getContext()).andStubReturn(GadgetsHandlerApi.RenderingContext.CONTAINER);
replay();
gadgetHandler.getJs(request);
}
@Test
public void testCreateProxyUri() throws Exception {
GadgetsHandlerApi.ImageParams image = mock(GadgetsHandlerApi.ImageParams.class);
expect(image.getDoNotExpand()).andStubReturn(true);
expect(image.getHeight()).andStubReturn(120);
expect(image.getWidth()).andStubReturn(210);
expect(image.getQuality()).andStubReturn(77);
GadgetsHandlerApi.ProxyRequest request = mock(GadgetsHandlerApi.ProxyRequest.class);
expect(request.getContainer()).andStubReturn(CONTAINER);
expect(request.getUrl()).andStubReturn(RESOURCE);
expect(request.getRefresh()).andStubReturn(new Integer(333));
expect(request.getDebug()).andStubReturn(true);
expect(request.getFallbackUrl()).andStubReturn(FALLBACK);
expect(request.getGadget()).andStubReturn(FakeProcessor.SPEC_URL.toString());
expect(request.getIgnoreCache()).andStubReturn(true);
expect(request.getImageParams()).andStubReturn(image);
expect(request.getRewriteMimeType()).andStubReturn("image/png");
expect(request.getSanitize()).andStubReturn(true);
replay();
ProxyUri pUri = gadgetHandler.createProxyUri(request);
ProxyUri expectedUri = new ProxyUri(333, true, true, CONTAINER,
FakeProcessor.SPEC_URL.toString(), RESOURCE);
expectedUri.setRewriteMimeType("image/png").setSanitizeContent(true);
expectedUri.setResize(210, 120, 77, true).setFallbackUrl(FALLBACK);
assertEquals(pUri, expectedUri);
verify();
}
@Test
public void testValidateProxyResponse() throws Exception {
GadgetsHandlerApi.ProxyResponse response = gadgetHandler.createProxyResponse(RESOURCE, null,
ImmutableSet.<String> of("*"), 1000001L);
BeanDelegator.validateDelegator(response);
assertEquals(RESOURCE, response.getProxyUrl());
assertNull(response.getProxyContent());
}
@Test
public void testCreateProxyResponse() throws Exception {
HttpResponseBuilder httpResponse = new HttpResponseBuilder();
httpResponse.setContent("Content");
httpResponse.addHeader("header", "hval");
httpResponse.setEncoding(Charset.forName("UTF8"));
httpResponse.setHttpStatusCode(404);
GadgetsHandlerApi.ProxyResponse response = gadgetHandler.createProxyResponse(RESOURCE,
httpResponse.create(), ImmutableSet.<String> of("*"), 1000001L);
BeanDelegator.validateDelegator(response);
assertEquals("Content",
new String(Base64.decodeBase64(response.getProxyContent().getContentBase64())));
assertEquals(404, response.getProxyContent().getCode());
assertEquals(2, response.getProxyContent().getHeaders().size());
assertEquals("Date", response.getProxyContent().getHeaders().get(0).getName());
assertEquals("header", response.getProxyContent().getHeaders().get(1).getName());
assertEquals("hval", response.getProxyContent().getHeaders().get(1).getValue());
assertEquals(1000001L, response.getExpireTimeMs().longValue());
}
@Test
public void testFilterProxyResponse() throws Exception {
HttpResponse httpResponse = new HttpResponse("data");
GadgetsHandlerApi.ProxyResponse response = gadgetHandler.createProxyResponse(RESOURCE,
httpResponse, ImmutableSet.<String> of("proxyurl"), 1000001L);
assertNull(response.getProxyContent());
assertEquals(RESOURCE, response.getProxyUrl());
}
@Test
public void testGetProxySimple() throws Exception {
List<String> fields = ImmutableList.of("proxyurl");
Uri resUri = Uri.parse("server.com/gadgets/proxy?url=" + RESOURCE);
GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, fields);
Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
ImmutableList.of(resUri));
replay();
GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
assertEquals(1, uriCapture.getValue().size());
ProxyUri pUri = uriCapture.getValue().get(0);
assertEquals(CONTAINER, pUri.getContainer());
assertEquals(resUri, response.getProxyUrl());
assertNull(response.getProxyContent());
assertEquals(timeSource.currentTimeMillis() + HttpUtil.getDefaultTtl() * 1000, response
.getExpireTimeMs().longValue());
verify();
}
@Test(expected = ProcessingException.class)
public void testGetProxyNoContainer() throws Exception {
List<String> fields = ImmutableList.of("*");
GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, null, fields);
gadgetHandler.getProxy(request);
}
@Test(expected = ProcessingException.class)
public void testGetProxyNoResource() throws Exception {
List<String> fields = ImmutableList.of("*");
GadgetsHandlerApi.ProxyRequest request = createProxyRequest(null, CONTAINER, fields);
gadgetHandler.getProxy(request);
}
@Test(expected = ProcessingException.class)
public void testGetProxyNoFields() throws Exception {
GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, null);
gadgetHandler.getProxy(request);
}
@Test
public void testGetProxyData() throws Exception {
List<String> fields = ImmutableList.of("proxycontent.*");
Uri resUri = Uri.parse("server.com/gadgets/proxy?url=" + RESOURCE);
GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, fields);
Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
ImmutableList.of(resUri));
HttpResponseBuilder builder = new HttpResponseBuilder();
builder.setExpirationTime(20000).setContent("response");
HttpResponse httpResponse = builder.create();
expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andReturn(httpResponse);
replay();
GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
assertEquals(1, uriCapture.getValue().size());
ProxyUri pUri = uriCapture.getValue().get(0);
assertEquals(CONTAINER, pUri.getContainer());
assertNull(response.getProxyUrl());
assertEquals("response",
new String(Base64.decodeBase64(response.getProxyContent().getContentBase64())));
assertEquals(20000L, response.getExpireTimeMs().longValue());
verify();
}
@Test
public void testGetProxyEmptyData() throws Exception {
List<String> fields = ImmutableList.of("proxycontent.*");
Uri resUri = Uri.parse("server.com/gadgets/proxy?url=" + RESOURCE);
GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, fields);
Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
ImmutableList.of(resUri));
HttpResponse httpResponse = new HttpResponseBuilder().setHttpStatusCode(504).create();
expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andReturn(httpResponse);
replay();
GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
assertEquals(1, uriCapture.getValue().size());
ProxyUri pUri = uriCapture.getValue().get(0);
assertEquals(CONTAINER, pUri.getContainer());
assertNull(response.getProxyUrl());
assertEquals("", response.getProxyContent().getContentBase64());
assertEquals(504, response.getProxyContent().getCode());
verify();
}
@Test(expected = ProcessingException.class)
public void testGetProxyDataFail() throws Exception {
List<String> fields = ImmutableList.of("proxycontent.*");
Uri resUri = Uri.parse("server.com/gadgets/proxy?url=" + RESOURCE);
GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, fields);
Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
ImmutableList.of(resUri));
new HttpResponse("response");
expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andThrow(
new GadgetException(Code.FAILED_TO_RETRIEVE_CONTENT));
replay();
gadgetHandler.getProxy(request);
}
@Test
public void testCreateCajaResponse() throws Exception {
String goldenEntries[][] = { { "name1", "LINT", "msg1" }, { "name2", "LINT", "msg2" } };
List<GadgetsHandlerApi.Message> goldenMessages = Lists.newArrayList();
for (String[] goldenEntry : goldenEntries) {
GadgetsHandlerApi.Message m = mock(GadgetsHandlerApi.Message.class);
expect(m.getName()).andReturn(goldenEntry[0]);
expect(m.getLevel()).andReturn(GadgetsHandlerApi.MessageLevel.valueOf(goldenEntry[1]));
expect(m.getMessage()).andReturn(goldenEntry[2]);
goldenMessages.add(m);
}
replay();
Uri jsUri = Uri.parse("http://www.shindig.com/js");
GadgetsHandlerApi.CajaResponse jsResponse = gadgetHandler.createCajaResponse(jsUri, "html",
"js", goldenMessages, ImmutableSet.of("*"), null);
BeanDelegator.validateDelegator(jsResponse);
assertEquals("html", jsResponse.getHtml());
assertEquals("js", jsResponse.getJs());
List<GadgetsHandlerApi.Message> response = jsResponse.getMessages();
assertEquals(goldenMessages.size(), response.size());
for (int i = 0; i < response.size(); i++) {
assertEquals(goldenEntries[i][0], response.get(i).getName());
assertEquals(goldenEntries[i][1], response.get(i).getLevel().name());
assertEquals(goldenEntries[i][2], response.get(i).getMessage());
}
}
private GadgetsHandlerApi.AuthContext createAuthContext(String ownerId, String viewerId) {
GadgetsHandlerApi.AuthContext authContext = mock(GadgetsHandlerApi.AuthContext.class);
if (ownerId != null) {
EasyMock.expect(authContext.getOwnerId()).andReturn(ownerId).once();
}
if (viewerId != null) {
EasyMock.expect(authContext.getViewerId()).andReturn(viewerId).once();
}
EasyMock.expect(authContext.getExpiresAt()).andReturn(TOKEN_EXPIRY_TIME_MS).anyTimes();
return authContext;
}
private GadgetsHandlerApi.MetadataRequest createMetadataRequest(Uri url, String container,
String view, GadgetsHandlerApi.AuthContext authContext, List<String> fields) {
GadgetsHandlerApi.MetadataRequest request = mock(GadgetsHandlerApi.MetadataRequest.class);
EasyMock.expect(request.getFields()).andReturn(fields).anyTimes();
EasyMock.expect(request.getView()).andReturn(view).once();
EasyMock.expect(request.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(request.getContainer()).andReturn(container).anyTimes();
EasyMock.expect(request.getAuthContext()).andReturn(authContext).once();
return request;
}
private GadgetsHandlerApi.TokenRequest createTokenRequest(Uri url, String container,
GadgetsHandlerApi.AuthContext authContext, List<String> fields) {
GadgetsHandlerApi.TokenRequest request = mock(GadgetsHandlerApi.TokenRequest.class);
EasyMock.expect(request.getFields()).andReturn(fields).anyTimes();
EasyMock.expect(request.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(request.getContainer()).andReturn(container).anyTimes();
EasyMock.expect(request.getAuthContext()).andReturn(authContext).once();
return request;
}
private GadgetsHandlerApi.JsRequest createJsRequest(String gadget, String container,
List<String> fields, List<String> features, String repository) {
GadgetsHandlerApi.JsRequest request = mock(GadgetsHandlerApi.JsRequest.class);
EasyMock.expect(request.getFields()).andStubReturn(fields);
EasyMock.expect(request.getContainer()).andStubReturn(container);
EasyMock.expect(request.getGadget()).andStubReturn(gadget);
EasyMock.expect(request.getFeatures()).andStubReturn(features);
EasyMock.expect(request.getRepository()).andStubReturn(repository);
return request;
}
private GadgetsHandlerApi.ProxyRequest createProxyRequest(Uri url, String container,
List<String> fields) {
GadgetsHandlerApi.ProxyRequest request = mock(GadgetsHandlerApi.ProxyRequest.class);
EasyMock.expect(request.getFields()).andStubReturn(fields);
EasyMock.expect(request.getContainer()).andStubReturn(container);
EasyMock.expect(request.getUrl()).andStubReturn(url);
return request;
}
private class FakeSecurityTokenCodec implements SecurityTokenCodec {
public SecurityToken authContext = null;
public SecurityTokenException exc = null;
public String encodedToken = null;
public String encodeToken(SecurityToken authContext) throws SecurityTokenException {
this.authContext = authContext;
if (exc != null) {
throw exc;
}
return encodedToken;
}
public SecurityToken createToken(Map<String, String> tokenParameters)
throws SecurityTokenException {
if (exc != null) {
throw exc;
}
return authContext;
}
public int getTokenTimeToLive() {
return 0; // Not used.
}
public int getTokenTimeToLive(String container) {
return 0; // Not used.
}
}
}
|
googleapis/google-cloud-java | 36,316 | java-meet/proto-google-cloud-meet-v2beta/src/main/java/com/google/apps/meet/v2beta/ListTranscriptsResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/apps/meet/v2beta/service.proto
// Protobuf Java Version: 3.25.8
package com.google.apps.meet.v2beta;
/**
*
*
* <pre>
* Response for ListTranscripts method.
* </pre>
*
* Protobuf type {@code google.apps.meet.v2beta.ListTranscriptsResponse}
*/
public final class ListTranscriptsResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.apps.meet.v2beta.ListTranscriptsResponse)
ListTranscriptsResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListTranscriptsResponse.newBuilder() to construct.
private ListTranscriptsResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListTranscriptsResponse() {
transcripts_ = java.util.Collections.emptyList();
nextPageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListTranscriptsResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.apps.meet.v2beta.ServiceProto
.internal_static_google_apps_meet_v2beta_ListTranscriptsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.apps.meet.v2beta.ServiceProto
.internal_static_google_apps_meet_v2beta_ListTranscriptsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.apps.meet.v2beta.ListTranscriptsResponse.class,
com.google.apps.meet.v2beta.ListTranscriptsResponse.Builder.class);
}
public static final int TRANSCRIPTS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.apps.meet.v2beta.Transcript> transcripts_;
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
@java.lang.Override
public java.util.List<com.google.apps.meet.v2beta.Transcript> getTranscriptsList() {
return transcripts_;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.apps.meet.v2beta.TranscriptOrBuilder>
getTranscriptsOrBuilderList() {
return transcripts_;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
@java.lang.Override
public int getTranscriptsCount() {
return transcripts_.size();
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
@java.lang.Override
public com.google.apps.meet.v2beta.Transcript getTranscripts(int index) {
return transcripts_.get(index);
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
@java.lang.Override
public com.google.apps.meet.v2beta.TranscriptOrBuilder getTranscriptsOrBuilder(int index) {
return transcripts_.get(index);
}
public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Token to be circulated back for further List call if current List doesn't
* include all the transcripts. Unset if all transcripts are returned.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
@java.lang.Override
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
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();
nextPageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* Token to be circulated back for further List call if current List doesn't
* include all the transcripts. Unset if all transcripts are returned.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 {
for (int i = 0; i < transcripts_.size(); i++) {
output.writeMessage(1, transcripts_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < transcripts_.size(); i++) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, transcripts_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_);
}
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.apps.meet.v2beta.ListTranscriptsResponse)) {
return super.equals(obj);
}
com.google.apps.meet.v2beta.ListTranscriptsResponse other =
(com.google.apps.meet.v2beta.ListTranscriptsResponse) obj;
if (!getTranscriptsList().equals(other.getTranscriptsList())) return false;
if (!getNextPageToken().equals(other.getNextPageToken())) 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 (getTranscriptsCount() > 0) {
hash = (37 * hash) + TRANSCRIPTS_FIELD_NUMBER;
hash = (53 * hash) + getTranscriptsList().hashCode();
}
hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getNextPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse parseFrom(
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse 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.apps.meet.v2beta.ListTranscriptsResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse 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.apps.meet.v2beta.ListTranscriptsResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse 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.apps.meet.v2beta.ListTranscriptsResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse 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.apps.meet.v2beta.ListTranscriptsResponse 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;
}
/**
*
*
* <pre>
* Response for ListTranscripts method.
* </pre>
*
* Protobuf type {@code google.apps.meet.v2beta.ListTranscriptsResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.apps.meet.v2beta.ListTranscriptsResponse)
com.google.apps.meet.v2beta.ListTranscriptsResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.apps.meet.v2beta.ServiceProto
.internal_static_google_apps_meet_v2beta_ListTranscriptsResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.apps.meet.v2beta.ServiceProto
.internal_static_google_apps_meet_v2beta_ListTranscriptsResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.apps.meet.v2beta.ListTranscriptsResponse.class,
com.google.apps.meet.v2beta.ListTranscriptsResponse.Builder.class);
}
// Construct using com.google.apps.meet.v2beta.ListTranscriptsResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (transcriptsBuilder_ == null) {
transcripts_ = java.util.Collections.emptyList();
} else {
transcripts_ = null;
transcriptsBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
nextPageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.apps.meet.v2beta.ServiceProto
.internal_static_google_apps_meet_v2beta_ListTranscriptsResponse_descriptor;
}
@java.lang.Override
public com.google.apps.meet.v2beta.ListTranscriptsResponse getDefaultInstanceForType() {
return com.google.apps.meet.v2beta.ListTranscriptsResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.apps.meet.v2beta.ListTranscriptsResponse build() {
com.google.apps.meet.v2beta.ListTranscriptsResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.apps.meet.v2beta.ListTranscriptsResponse buildPartial() {
com.google.apps.meet.v2beta.ListTranscriptsResponse result =
new com.google.apps.meet.v2beta.ListTranscriptsResponse(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.apps.meet.v2beta.ListTranscriptsResponse result) {
if (transcriptsBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
transcripts_ = java.util.Collections.unmodifiableList(transcripts_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.transcripts_ = transcripts_;
} else {
result.transcripts_ = transcriptsBuilder_.build();
}
}
private void buildPartial0(com.google.apps.meet.v2beta.ListTranscriptsResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.nextPageToken_ = nextPageToken_;
}
}
@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.apps.meet.v2beta.ListTranscriptsResponse) {
return mergeFrom((com.google.apps.meet.v2beta.ListTranscriptsResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.apps.meet.v2beta.ListTranscriptsResponse other) {
if (other == com.google.apps.meet.v2beta.ListTranscriptsResponse.getDefaultInstance())
return this;
if (transcriptsBuilder_ == null) {
if (!other.transcripts_.isEmpty()) {
if (transcripts_.isEmpty()) {
transcripts_ = other.transcripts_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureTranscriptsIsMutable();
transcripts_.addAll(other.transcripts_);
}
onChanged();
}
} else {
if (!other.transcripts_.isEmpty()) {
if (transcriptsBuilder_.isEmpty()) {
transcriptsBuilder_.dispose();
transcriptsBuilder_ = null;
transcripts_ = other.transcripts_;
bitField0_ = (bitField0_ & ~0x00000001);
transcriptsBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getTranscriptsFieldBuilder()
: null;
} else {
transcriptsBuilder_.addAllMessages(other.transcripts_);
}
}
}
if (!other.getNextPageToken().isEmpty()) {
nextPageToken_ = other.nextPageToken_;
bitField0_ |= 0x00000002;
onChanged();
}
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 10:
{
com.google.apps.meet.v2beta.Transcript m =
input.readMessage(
com.google.apps.meet.v2beta.Transcript.parser(), extensionRegistry);
if (transcriptsBuilder_ == null) {
ensureTranscriptsIsMutable();
transcripts_.add(m);
} else {
transcriptsBuilder_.addMessage(m);
}
break;
} // case 10
case 18:
{
nextPageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
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.apps.meet.v2beta.Transcript> transcripts_ =
java.util.Collections.emptyList();
private void ensureTranscriptsIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
transcripts_ =
new java.util.ArrayList<com.google.apps.meet.v2beta.Transcript>(transcripts_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.apps.meet.v2beta.Transcript,
com.google.apps.meet.v2beta.Transcript.Builder,
com.google.apps.meet.v2beta.TranscriptOrBuilder>
transcriptsBuilder_;
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public java.util.List<com.google.apps.meet.v2beta.Transcript> getTranscriptsList() {
if (transcriptsBuilder_ == null) {
return java.util.Collections.unmodifiableList(transcripts_);
} else {
return transcriptsBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public int getTranscriptsCount() {
if (transcriptsBuilder_ == null) {
return transcripts_.size();
} else {
return transcriptsBuilder_.getCount();
}
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public com.google.apps.meet.v2beta.Transcript getTranscripts(int index) {
if (transcriptsBuilder_ == null) {
return transcripts_.get(index);
} else {
return transcriptsBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder setTranscripts(int index, com.google.apps.meet.v2beta.Transcript value) {
if (transcriptsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureTranscriptsIsMutable();
transcripts_.set(index, value);
onChanged();
} else {
transcriptsBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder setTranscripts(
int index, com.google.apps.meet.v2beta.Transcript.Builder builderForValue) {
if (transcriptsBuilder_ == null) {
ensureTranscriptsIsMutable();
transcripts_.set(index, builderForValue.build());
onChanged();
} else {
transcriptsBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder addTranscripts(com.google.apps.meet.v2beta.Transcript value) {
if (transcriptsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureTranscriptsIsMutable();
transcripts_.add(value);
onChanged();
} else {
transcriptsBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder addTranscripts(int index, com.google.apps.meet.v2beta.Transcript value) {
if (transcriptsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureTranscriptsIsMutable();
transcripts_.add(index, value);
onChanged();
} else {
transcriptsBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder addTranscripts(com.google.apps.meet.v2beta.Transcript.Builder builderForValue) {
if (transcriptsBuilder_ == null) {
ensureTranscriptsIsMutable();
transcripts_.add(builderForValue.build());
onChanged();
} else {
transcriptsBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder addTranscripts(
int index, com.google.apps.meet.v2beta.Transcript.Builder builderForValue) {
if (transcriptsBuilder_ == null) {
ensureTranscriptsIsMutable();
transcripts_.add(index, builderForValue.build());
onChanged();
} else {
transcriptsBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder addAllTranscripts(
java.lang.Iterable<? extends com.google.apps.meet.v2beta.Transcript> values) {
if (transcriptsBuilder_ == null) {
ensureTranscriptsIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, transcripts_);
onChanged();
} else {
transcriptsBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder clearTranscripts() {
if (transcriptsBuilder_ == null) {
transcripts_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
transcriptsBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public Builder removeTranscripts(int index) {
if (transcriptsBuilder_ == null) {
ensureTranscriptsIsMutable();
transcripts_.remove(index);
onChanged();
} else {
transcriptsBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public com.google.apps.meet.v2beta.Transcript.Builder getTranscriptsBuilder(int index) {
return getTranscriptsFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public com.google.apps.meet.v2beta.TranscriptOrBuilder getTranscriptsOrBuilder(int index) {
if (transcriptsBuilder_ == null) {
return transcripts_.get(index);
} else {
return transcriptsBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public java.util.List<? extends com.google.apps.meet.v2beta.TranscriptOrBuilder>
getTranscriptsOrBuilderList() {
if (transcriptsBuilder_ != null) {
return transcriptsBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(transcripts_);
}
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public com.google.apps.meet.v2beta.Transcript.Builder addTranscriptsBuilder() {
return getTranscriptsFieldBuilder()
.addBuilder(com.google.apps.meet.v2beta.Transcript.getDefaultInstance());
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public com.google.apps.meet.v2beta.Transcript.Builder addTranscriptsBuilder(int index) {
return getTranscriptsFieldBuilder()
.addBuilder(index, com.google.apps.meet.v2beta.Transcript.getDefaultInstance());
}
/**
*
*
* <pre>
* List of transcripts in one page.
* </pre>
*
* <code>repeated .google.apps.meet.v2beta.Transcript transcripts = 1;</code>
*/
public java.util.List<com.google.apps.meet.v2beta.Transcript.Builder>
getTranscriptsBuilderList() {
return getTranscriptsFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.apps.meet.v2beta.Transcript,
com.google.apps.meet.v2beta.Transcript.Builder,
com.google.apps.meet.v2beta.TranscriptOrBuilder>
getTranscriptsFieldBuilder() {
if (transcriptsBuilder_ == null) {
transcriptsBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.apps.meet.v2beta.Transcript,
com.google.apps.meet.v2beta.Transcript.Builder,
com.google.apps.meet.v2beta.TranscriptOrBuilder>(
transcripts_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
transcripts_ = null;
}
return transcriptsBuilder_;
}
private java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Token to be circulated back for further List call if current List doesn't
* include all the transcripts. Unset if all transcripts are returned.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
nextPageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Token to be circulated back for further List call if current List doesn't
* include all the transcripts. Unset if all transcripts are returned.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Token to be circulated back for further List call if current List doesn't
* include all the transcripts. Unset if all transcripts are returned.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Token to be circulated back for further List call if current List doesn't
* include all the transcripts. Unset if all transcripts are returned.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearNextPageToken() {
nextPageToken_ = getDefaultInstance().getNextPageToken();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Token to be circulated back for further List call if current List doesn't
* include all the transcripts. Unset if all transcripts are returned.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The bytes for nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.apps.meet.v2beta.ListTranscriptsResponse)
}
// @@protoc_insertion_point(class_scope:google.apps.meet.v2beta.ListTranscriptsResponse)
private static final com.google.apps.meet.v2beta.ListTranscriptsResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.apps.meet.v2beta.ListTranscriptsResponse();
}
public static com.google.apps.meet.v2beta.ListTranscriptsResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListTranscriptsResponse> PARSER =
new com.google.protobuf.AbstractParser<ListTranscriptsResponse>() {
@java.lang.Override
public ListTranscriptsResponse 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<ListTranscriptsResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListTranscriptsResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.apps.meet.v2beta.ListTranscriptsResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,348 | java-gkehub/proto-google-cloud-gkehub-v1beta/src/main/java/com/google/cloud/gkehub/policycontroller/v1beta/MonitoringConfig.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/gkehub/policycontroller/v1beta/policycontroller.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.gkehub.policycontroller.v1beta;
/**
*
*
* <pre>
* MonitoringConfig specifies the backends Policy Controller should
* export metrics to. For example, to specify metrics should be exported to
* Cloud Monitoring and Prometheus, specify
* backends: ["cloudmonitoring", "prometheus"]
* </pre>
*
* Protobuf type {@code google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig}
*/
public final class MonitoringConfig extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig)
MonitoringConfigOrBuilder {
private static final long serialVersionUID = 0L;
// Use MonitoringConfig.newBuilder() to construct.
private MonitoringConfig(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private MonitoringConfig() {
backends_ = java.util.Collections.emptyList();
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new MonitoringConfig();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.gkehub.policycontroller.v1beta.PolicyControllerProto
.internal_static_google_cloud_gkehub_policycontroller_v1beta_MonitoringConfig_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.gkehub.policycontroller.v1beta.PolicyControllerProto
.internal_static_google_cloud_gkehub_policycontroller_v1beta_MonitoringConfig_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.class,
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.Builder.class);
}
/**
*
*
* <pre>
* Supported backend options for monitoring
* </pre>
*
* Protobuf enum {@code
* google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend}
*/
public enum MonitoringBackend implements com.google.protobuf.ProtocolMessageEnum {
/**
*
*
* <pre>
* Backend cannot be determined
* </pre>
*
* <code>MONITORING_BACKEND_UNSPECIFIED = 0;</code>
*/
MONITORING_BACKEND_UNSPECIFIED(0),
/**
*
*
* <pre>
* Prometheus backend for monitoring
* </pre>
*
* <code>PROMETHEUS = 1;</code>
*/
PROMETHEUS(1),
/**
*
*
* <pre>
* Stackdriver/Cloud Monitoring backend for monitoring
* </pre>
*
* <code>CLOUD_MONITORING = 2;</code>
*/
CLOUD_MONITORING(2),
UNRECOGNIZED(-1),
;
/**
*
*
* <pre>
* Backend cannot be determined
* </pre>
*
* <code>MONITORING_BACKEND_UNSPECIFIED = 0;</code>
*/
public static final int MONITORING_BACKEND_UNSPECIFIED_VALUE = 0;
/**
*
*
* <pre>
* Prometheus backend for monitoring
* </pre>
*
* <code>PROMETHEUS = 1;</code>
*/
public static final int PROMETHEUS_VALUE = 1;
/**
*
*
* <pre>
* Stackdriver/Cloud Monitoring backend for monitoring
* </pre>
*
* <code>CLOUD_MONITORING = 2;</code>
*/
public static final int CLOUD_MONITORING_VALUE = 2;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static MonitoringBackend valueOf(int value) {
return forNumber(value);
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
*/
public static MonitoringBackend forNumber(int value) {
switch (value) {
case 0:
return MONITORING_BACKEND_UNSPECIFIED;
case 1:
return PROMETHEUS;
case 2:
return CLOUD_MONITORING;
default:
return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<MonitoringBackend>
internalGetValueMap() {
return internalValueMap;
}
private static final com.google.protobuf.Internal.EnumLiteMap<MonitoringBackend>
internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<MonitoringBackend>() {
public MonitoringBackend findValueByNumber(int number) {
return MonitoringBackend.forNumber(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalStateException(
"Can't get the descriptor of an unrecognized enum value.");
}
return getDescriptor().getValues().get(ordinal());
}
public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
return com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.getDescriptor()
.getEnumTypes()
.get(0);
}
private static final MonitoringBackend[] VALUES = values();
public static MonitoringBackend valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
}
if (desc.getIndex() == -1) {
return UNRECOGNIZED;
}
return VALUES[desc.getIndex()];
}
private final int value;
private MonitoringBackend(int value) {
this.value = value;
}
// @@protoc_insertion_point(enum_scope:google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend)
}
public static final int BACKENDS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<java.lang.Integer> backends_;
private static final com.google.protobuf.Internal.ListAdapter.Converter<
java.lang.Integer,
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend>
backends_converter_ =
new com.google.protobuf.Internal.ListAdapter.Converter<
java.lang.Integer,
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
.MonitoringBackend>() {
public com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
.MonitoringBackend
convert(java.lang.Integer from) {
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend
result =
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
.MonitoringBackend.forNumber(from);
return result == null
? com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
.MonitoringBackend.UNRECOGNIZED
: result;
}
};
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @return A list containing the backends.
*/
@java.lang.Override
public java.util.List<
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend>
getBackendsList() {
return new com.google.protobuf.Internal.ListAdapter<
java.lang.Integer,
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend>(
backends_, backends_converter_);
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @return The count of backends.
*/
@java.lang.Override
public int getBackendsCount() {
return backends_.size();
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param index The index of the element to return.
* @return The backends at the given index.
*/
@java.lang.Override
public com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend
getBackends(int index) {
return backends_converter_.convert(backends_.get(index));
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @return A list containing the enum numeric values on the wire for backends.
*/
@java.lang.Override
public java.util.List<java.lang.Integer> getBackendsValueList() {
return backends_;
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param index The index of the value to return.
* @return The enum numeric value on the wire of backends at the given index.
*/
@java.lang.Override
public int getBackendsValue(int index) {
return backends_.get(index);
}
private int backendsMemoizedSerializedSize;
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 {
getSerializedSize();
if (getBackendsList().size() > 0) {
output.writeUInt32NoTag(10);
output.writeUInt32NoTag(backendsMemoizedSerializedSize);
}
for (int i = 0; i < backends_.size(); i++) {
output.writeEnumNoTag(backends_.get(i));
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
{
int dataSize = 0;
for (int i = 0; i < backends_.size(); i++) {
dataSize += com.google.protobuf.CodedOutputStream.computeEnumSizeNoTag(backends_.get(i));
}
size += dataSize;
if (!getBackendsList().isEmpty()) {
size += 1;
size += com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(dataSize);
}
backendsMemoizedSerializedSize = dataSize;
}
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.gkehub.policycontroller.v1beta.MonitoringConfig)) {
return super.equals(obj);
}
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig other =
(com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig) obj;
if (!backends_.equals(other.backends_)) 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 (getBackendsCount() > 0) {
hash = (37 * hash) + BACKENDS_FIELD_NUMBER;
hash = (53 * hash) + backends_.hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig 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.gkehub.policycontroller.v1beta.MonitoringConfig parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig 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.gkehub.policycontroller.v1beta.MonitoringConfig parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig 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.gkehub.policycontroller.v1beta.MonitoringConfig parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig 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.gkehub.policycontroller.v1beta.MonitoringConfig parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig 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.gkehub.policycontroller.v1beta.MonitoringConfig 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;
}
/**
*
*
* <pre>
* MonitoringConfig specifies the backends Policy Controller should
* export metrics to. For example, to specify metrics should be exported to
* Cloud Monitoring and Prometheus, specify
* backends: ["cloudmonitoring", "prometheus"]
* </pre>
*
* Protobuf type {@code google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig)
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfigOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.gkehub.policycontroller.v1beta.PolicyControllerProto
.internal_static_google_cloud_gkehub_policycontroller_v1beta_MonitoringConfig_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.gkehub.policycontroller.v1beta.PolicyControllerProto
.internal_static_google_cloud_gkehub_policycontroller_v1beta_MonitoringConfig_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.class,
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.Builder.class);
}
// Construct using com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
backends_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.gkehub.policycontroller.v1beta.PolicyControllerProto
.internal_static_google_cloud_gkehub_policycontroller_v1beta_MonitoringConfig_descriptor;
}
@java.lang.Override
public com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
getDefaultInstanceForType() {
return com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig build() {
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig buildPartial() {
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig result =
new com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig result) {
if (((bitField0_ & 0x00000001) != 0)) {
backends_ = java.util.Collections.unmodifiableList(backends_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.backends_ = backends_;
}
private void buildPartial0(
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig result) {
int from_bitField0_ = bitField0_;
}
@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.gkehub.policycontroller.v1beta.MonitoringConfig) {
return mergeFrom((com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig other) {
if (other
== com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.getDefaultInstance())
return this;
if (!other.backends_.isEmpty()) {
if (backends_.isEmpty()) {
backends_ = other.backends_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureBackendsIsMutable();
backends_.addAll(other.backends_);
}
onChanged();
}
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 8:
{
int tmpRaw = input.readEnum();
ensureBackendsIsMutable();
backends_.add(tmpRaw);
break;
} // case 8
case 10:
{
int length = input.readRawVarint32();
int oldLimit = input.pushLimit(length);
while (input.getBytesUntilLimit() > 0) {
int tmpRaw = input.readEnum();
ensureBackendsIsMutable();
backends_.add(tmpRaw);
}
input.popLimit(oldLimit);
break;
} // case 10
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<java.lang.Integer> backends_ = java.util.Collections.emptyList();
private void ensureBackendsIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
backends_ = new java.util.ArrayList<java.lang.Integer>(backends_);
bitField0_ |= 0x00000001;
}
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @return A list containing the backends.
*/
public java.util.List<
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend>
getBackendsList() {
return new com.google.protobuf.Internal.ListAdapter<
java.lang.Integer,
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend>(
backends_, backends_converter_);
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @return The count of backends.
*/
public int getBackendsCount() {
return backends_.size();
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param index The index of the element to return.
* @return The backends at the given index.
*/
public com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend
getBackends(int index) {
return backends_converter_.convert(backends_.get(index));
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param index The index to set the value at.
* @param value The backends to set.
* @return This builder for chaining.
*/
public Builder setBackends(
int index,
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend value) {
if (value == null) {
throw new NullPointerException();
}
ensureBackendsIsMutable();
backends_.set(index, value.getNumber());
onChanged();
return this;
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param value The backends to add.
* @return This builder for chaining.
*/
public Builder addBackends(
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend value) {
if (value == null) {
throw new NullPointerException();
}
ensureBackendsIsMutable();
backends_.add(value.getNumber());
onChanged();
return this;
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param values The backends to add.
* @return This builder for chaining.
*/
public Builder addAllBackends(
java.lang.Iterable<
? extends
com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
.MonitoringBackend>
values) {
ensureBackendsIsMutable();
for (com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend
value : values) {
backends_.add(value.getNumber());
}
onChanged();
return this;
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @return This builder for chaining.
*/
public Builder clearBackends() {
backends_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @return A list containing the enum numeric values on the wire for backends.
*/
public java.util.List<java.lang.Integer> getBackendsValueList() {
return java.util.Collections.unmodifiableList(backends_);
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param index The index of the value to return.
* @return The enum numeric value on the wire of backends at the given index.
*/
public int getBackendsValue(int index) {
return backends_.get(index);
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param index The index to set the value at.
* @param value The enum numeric value on the wire for backends to set.
* @return This builder for chaining.
*/
public Builder setBackendsValue(int index, int value) {
ensureBackendsIsMutable();
backends_.set(index, value);
onChanged();
return this;
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param value The enum numeric value on the wire for backends to add.
* @return This builder for chaining.
*/
public Builder addBackendsValue(int value) {
ensureBackendsIsMutable();
backends_.add(value);
onChanged();
return this;
}
/**
*
*
* <pre>
* Specifies the list of backends Policy Controller will export to.
* An empty list would effectively disable metrics export.
* </pre>
*
* <code>
* repeated .google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig.MonitoringBackend backends = 1;
* </code>
*
* @param values The enum numeric values on the wire for backends to add.
* @return This builder for chaining.
*/
public Builder addAllBackendsValue(java.lang.Iterable<java.lang.Integer> values) {
ensureBackendsIsMutable();
for (int value : values) {
backends_.add(value);
}
onChanged();
return this;
}
@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.gkehub.policycontroller.v1beta.MonitoringConfig)
}
// @@protoc_insertion_point(class_scope:google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig)
private static final com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig();
}
public static com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<MonitoringConfig> PARSER =
new com.google.protobuf.AbstractParser<MonitoringConfig>() {
@java.lang.Override
public MonitoringConfig 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<MonitoringConfig> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<MonitoringConfig> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.gkehub.policycontroller.v1beta.MonitoringConfig
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
apache/tomcat | 36,305 | java/org/apache/catalina/deploy/NamingResourcesImpl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.deploy;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serial;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.naming.NamingException;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.JmxEnabled;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.Server;
import org.apache.catalina.mbeans.MBeanUtils;
import org.apache.catalina.util.Introspection;
import org.apache.catalina.util.LifecycleMBeanBase;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.naming.ContextBindings;
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.descriptor.web.ContextEjb;
import org.apache.tomcat.util.descriptor.web.ContextEnvironment;
import org.apache.tomcat.util.descriptor.web.ContextLocalEjb;
import org.apache.tomcat.util.descriptor.web.ContextResource;
import org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef;
import org.apache.tomcat.util.descriptor.web.ContextResourceLink;
import org.apache.tomcat.util.descriptor.web.ContextService;
import org.apache.tomcat.util.descriptor.web.ContextTransaction;
import org.apache.tomcat.util.descriptor.web.InjectionTarget;
import org.apache.tomcat.util.descriptor.web.MessageDestinationRef;
import org.apache.tomcat.util.descriptor.web.NamingResources;
import org.apache.tomcat.util.descriptor.web.ResourceBase;
import org.apache.tomcat.util.res.StringManager;
/**
* Holds and manages the naming resources defined in the Jakarta EE Naming Context and their associated JNDI context.
*/
public class NamingResourcesImpl extends LifecycleMBeanBase implements Serializable, NamingResources {
@Serial
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(NamingResourcesImpl.class);
private static final StringManager sm = StringManager.getManager(NamingResourcesImpl.class);
private volatile boolean resourceRequireExplicitRegistration = false;
// ----------------------------------------------------------- Constructors
/**
* Create a new NamingResources instance.
*/
public NamingResourcesImpl() {
// NOOP
}
// ----------------------------------------------------- Instance Variables
/**
* Associated container object.
*/
private Object container = null;
/**
* Set of naming entries, keyed by name.
*/
private final Set<String> entries = new HashSet<>();
/**
* The EJB resource references for this web application, keyed by name.
*/
private final Map<String,ContextEjb> ejbs = new HashMap<>();
/**
* The environment entries for this web application, keyed by name.
*/
private final Map<String,ContextEnvironment> envs = new HashMap<>();
/**
* The local EJB resource references for this web application, keyed by name.
*/
private final Map<String,ContextLocalEjb> localEjbs = new HashMap<>();
/**
* The message destination references for this web application, keyed by name.
*/
private final Map<String,MessageDestinationRef> mdrs = new HashMap<>();
/**
* The resource environment references for this web application, keyed by name.
*/
private final HashMap<String,ContextResourceEnvRef> resourceEnvRefs = new HashMap<>();
/**
* The resource references for this web application, keyed by name.
*/
private final HashMap<String,ContextResource> resources = new HashMap<>();
/**
* The resource links for this web application, keyed by name.
*/
private final HashMap<String,ContextResourceLink> resourceLinks = new HashMap<>();
/**
* The web service references for this web application, keyed by name.
*/
private final HashMap<String,ContextService> services = new HashMap<>();
/**
* The transaction for this webapp.
*/
private ContextTransaction transaction = null;
/**
* The property change support for this component.
*/
protected final PropertyChangeSupport support = new PropertyChangeSupport(this);
// ------------------------------------------------------------- Properties
@Override
public Object getContainer() {
return container;
}
/**
* Set the container with which the naming resources are associated.
*
* @param container the associated with the resources
*/
public void setContainer(Object container) {
this.container = container;
}
/**
* Set the transaction object.
*
* @param transaction the transaction descriptor
*/
public void setTransaction(ContextTransaction transaction) {
this.transaction = transaction;
}
/**
* @return the transaction object.
*/
public ContextTransaction getTransaction() {
return transaction;
}
/**
* Add an EJB resource reference for this web application.
*
* @param ejb New EJB resource reference
*/
public void addEjb(ContextEjb ejb) {
// Entries with lookup-name and ejb-link are an error (EE.5.5.2 / EE.5.5.3)
String ejbLink = ejb.getLink();
String lookupName = ejb.getLookupName();
if (ejbLink != null && !ejbLink.isEmpty() && lookupName != null && !lookupName.isEmpty()) {
throw new IllegalArgumentException(sm.getString("namingResources.ejbLookupLink", ejb.getName()));
}
if (entries.contains(ejb.getName())) {
return;
} else {
entries.add(ejb.getName());
}
synchronized (ejbs) {
ejb.setNamingResources(this);
ejbs.put(ejb.getName(), ejb);
}
support.firePropertyChange("ejb", null, ejb);
}
@Override
public void addEnvironment(ContextEnvironment environment) {
if (entries.contains(environment.getName())) {
ContextEnvironment ce = findEnvironment(environment.getName());
ContextResourceLink rl = findResourceLink(environment.getName());
if (ce != null) {
if (ce.getOverride()) {
removeEnvironment(environment.getName());
} else {
return;
}
} else if (rl != null) {
// Link. Need to look at the global resources
NamingResourcesImpl global = getServer().getGlobalNamingResources();
if (global.findEnvironment(rl.getGlobal()) != null) {
if (global.findEnvironment(rl.getGlobal()).getOverride()) {
removeResourceLink(environment.getName());
} else {
return;
}
}
} else {
// It exists but it isn't an env or a res link...
return;
}
}
List<InjectionTarget> injectionTargets = environment.getInjectionTargets();
String value = environment.getValue();
String lookupName = environment.getLookupName();
// Entries with injection targets but no value are effectively ignored
if (injectionTargets != null && !injectionTargets.isEmpty() && (value == null || value.isEmpty())) {
return;
}
// Entries with lookup-name and value are an error (EE.5.4.1.3)
if (value != null && !value.isEmpty() && lookupName != null && !lookupName.isEmpty()) {
throw new IllegalArgumentException(
sm.getString("namingResources.envEntryLookupValue", environment.getName()));
}
if (!checkResourceType(environment)) {
throw new IllegalArgumentException(
sm.getString("namingResources.resourceTypeFail", environment.getName(), environment.getType()));
}
entries.add(environment.getName());
synchronized (envs) {
environment.setNamingResources(this);
envs.put(environment.getName(), environment);
}
support.firePropertyChange("environment", null, environment);
// Register with JMX
if (resourceRequireExplicitRegistration) {
try {
MBeanUtils.createMBean(environment);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanCreateFail", environment.getName()), e);
}
}
}
// Container should be an instance of Server or Context. If it is anything
// else, return null which will trigger a NPE.
private Server getServer() {
if (container instanceof Server) {
return (Server) container;
}
if (container instanceof Context) {
// Could do this in one go. Lots of casts so split out for clarity
Engine engine = (Engine) ((Context) container).getParent().getParent();
return engine.getService().getServer();
}
return null;
}
/**
* Add a local EJB resource reference for this web application.
*
* @param ejb New EJB resource reference
*/
public void addLocalEjb(ContextLocalEjb ejb) {
if (entries.contains(ejb.getName())) {
return;
} else {
entries.add(ejb.getName());
}
synchronized (localEjbs) {
ejb.setNamingResources(this);
localEjbs.put(ejb.getName(), ejb);
}
support.firePropertyChange("localEjb", null, ejb);
}
/**
* Add a message destination reference for this web application.
*
* @param mdr New message destination reference
*/
public void addMessageDestinationRef(MessageDestinationRef mdr) {
if (entries.contains(mdr.getName())) {
return;
} else {
if (!checkResourceType(mdr)) {
throw new IllegalArgumentException(
sm.getString("namingResources.resourceTypeFail", mdr.getName(), mdr.getType()));
}
entries.add(mdr.getName());
}
synchronized (mdrs) {
mdr.setNamingResources(this);
mdrs.put(mdr.getName(), mdr);
}
support.firePropertyChange("messageDestinationRef", null, mdr);
}
/**
* Add a property change listener to this component.
*
* @param listener The listener to add
*/
public void addPropertyChangeListener(PropertyChangeListener listener) {
support.addPropertyChangeListener(listener);
}
@Override
public void addResource(ContextResource resource) {
if (entries.contains(resource.getName())) {
return;
} else {
if (!checkResourceType(resource)) {
throw new IllegalArgumentException(
sm.getString("namingResources.resourceTypeFail", resource.getName(), resource.getType()));
}
entries.add(resource.getName());
}
synchronized (resources) {
resource.setNamingResources(this);
resources.put(resource.getName(), resource);
}
support.firePropertyChange("resource", null, resource);
// Register with JMX
if (resourceRequireExplicitRegistration) {
try {
MBeanUtils.createMBean(resource);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanCreateFail", resource.getName()), e);
}
}
}
/**
* Add a resource environment reference for this web application.
*
* @param resource The resource
*/
public void addResourceEnvRef(ContextResourceEnvRef resource) {
if (entries.contains(resource.getName())) {
return;
} else {
if (!checkResourceType(resource)) {
throw new IllegalArgumentException(
sm.getString("namingResources.resourceTypeFail", resource.getName(), resource.getType()));
}
entries.add(resource.getName());
}
synchronized (resourceEnvRefs) {
resource.setNamingResources(this);
resourceEnvRefs.put(resource.getName(), resource);
}
support.firePropertyChange("resourceEnvRef", null, resource);
}
@Override
public void addResourceLink(ContextResourceLink resourceLink) {
if (entries.contains(resourceLink.getName())) {
return;
} else {
entries.add(resourceLink.getName());
}
synchronized (resourceLinks) {
resourceLink.setNamingResources(this);
resourceLinks.put(resourceLink.getName(), resourceLink);
}
support.firePropertyChange("resourceLink", null, resourceLink);
// Register with JMX
if (resourceRequireExplicitRegistration) {
try {
MBeanUtils.createMBean(resourceLink);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanCreateFail", resourceLink.getName()), e);
}
}
}
/**
* Add a web service reference for this web application.
*
* @param service New web service reference
*/
public void addService(ContextService service) {
if (entries.contains(service.getName())) {
return;
} else {
entries.add(service.getName());
}
synchronized (services) {
service.setNamingResources(this);
services.put(service.getName(), service);
}
support.firePropertyChange("service", null, service);
}
/**
* @return the EJB resource reference with the specified name, if any; otherwise, return <code>null</code>.
*
* @param name Name of the desired EJB resource reference
*/
public ContextEjb findEjb(String name) {
synchronized (ejbs) {
return ejbs.get(name);
}
}
/**
* @return the defined EJB resource references for this application. If there are none, a zero-length array is
* returned.
*/
public ContextEjb[] findEjbs() {
synchronized (ejbs) {
return ejbs.values().toArray(new ContextEjb[0]);
}
}
/**
* @return the environment entry with the specified name, if any; otherwise, return <code>null</code>.
*
* @param name Name of the desired environment entry
*/
public ContextEnvironment findEnvironment(String name) {
synchronized (envs) {
return envs.get(name);
}
}
/**
* @return the array of defined environment entries for this web application. If none have been defined, a
* zero-length array is returned.
*/
public ContextEnvironment[] findEnvironments() {
synchronized (envs) {
return envs.values().toArray(new ContextEnvironment[0]);
}
}
/**
* @return the local EJB resource reference with the specified name, if any; otherwise, return <code>null</code>.
*
* @param name Name of the desired EJB resource reference
*/
public ContextLocalEjb findLocalEjb(String name) {
synchronized (localEjbs) {
return localEjbs.get(name);
}
}
/**
* @return the defined local EJB resource references for this application. If there are none, a zero-length array is
* returned.
*/
public ContextLocalEjb[] findLocalEjbs() {
synchronized (localEjbs) {
return localEjbs.values().toArray(new ContextLocalEjb[0]);
}
}
/**
* @return the message destination reference with the specified name, if any; otherwise, return <code>null</code>.
*
* @param name Name of the desired message destination reference
*/
public MessageDestinationRef findMessageDestinationRef(String name) {
synchronized (mdrs) {
return mdrs.get(name);
}
}
/**
* @return the defined message destination references for this application. If there are none, a zero-length array
* is returned.
*/
public MessageDestinationRef[] findMessageDestinationRefs() {
synchronized (mdrs) {
return mdrs.values().toArray(new MessageDestinationRef[0]);
}
}
/**
* @return the resource reference with the specified name, if any; otherwise return <code>null</code>.
*
* @param name Name of the desired resource reference
*/
public ContextResource findResource(String name) {
synchronized (resources) {
return resources.get(name);
}
}
/**
* @return the resource link with the specified name, if any; otherwise return <code>null</code>.
*
* @param name Name of the desired resource link
*/
public ContextResourceLink findResourceLink(String name) {
synchronized (resourceLinks) {
return resourceLinks.get(name);
}
}
/**
* @return the defined resource links for this application. If none have been defined, a zero-length array is
* returned.
*/
public ContextResourceLink[] findResourceLinks() {
synchronized (resourceLinks) {
return resourceLinks.values().toArray(new ContextResourceLink[0]);
}
}
/**
* @return the defined resource references for this application. If none have been defined, a zero-length array is
* returned.
*/
public ContextResource[] findResources() {
synchronized (resources) {
return resources.values().toArray(new ContextResource[0]);
}
}
/**
* @return the resource environment reference type for the specified name, if any; otherwise return
* <code>null</code>.
*
* @param name Name of the desired resource environment reference
*/
public ContextResourceEnvRef findResourceEnvRef(String name) {
synchronized (resourceEnvRefs) {
return resourceEnvRefs.get(name);
}
}
/**
* @return the array of resource environment reference names for this web application. If none have been specified,
* a zero-length array is returned.
*/
public ContextResourceEnvRef[] findResourceEnvRefs() {
synchronized (resourceEnvRefs) {
return resourceEnvRefs.values().toArray(new ContextResourceEnvRef[0]);
}
}
/**
* @return the web service reference for the specified name, if any; otherwise return <code>null</code>.
*
* @param name Name of the desired web service
*/
public ContextService findService(String name) {
synchronized (services) {
return services.get(name);
}
}
/**
* @return the defined web service references for this application. If none have been defined, a zero-length array
* is returned.
*/
public ContextService[] findServices() {
synchronized (services) {
return services.values().toArray(new ContextService[0]);
}
}
/**
* Remove any EJB resource reference with the specified name.
*
* @param name Name of the EJB resource reference to remove
*/
public void removeEjb(String name) {
entries.remove(name);
ContextEjb ejb;
synchronized (ejbs) {
ejb = ejbs.remove(name);
}
if (ejb != null) {
support.firePropertyChange("ejb", ejb, null);
ejb.setNamingResources(null);
}
}
@Override
public void removeEnvironment(String name) {
entries.remove(name);
ContextEnvironment environment;
synchronized (envs) {
environment = envs.remove(name);
}
if (environment != null) {
support.firePropertyChange("environment", environment, null);
// De-register with JMX
if (resourceRequireExplicitRegistration) {
try {
MBeanUtils.destroyMBean(environment);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanDestroyFail", environment.getName()), e);
}
}
environment.setNamingResources(null);
}
}
/**
* Remove any local EJB resource reference with the specified name.
*
* @param name Name of the EJB resource reference to remove
*/
public void removeLocalEjb(String name) {
entries.remove(name);
ContextLocalEjb localEjb;
synchronized (localEjbs) {
localEjb = localEjbs.remove(name);
}
if (localEjb != null) {
support.firePropertyChange("localEjb", localEjb, null);
localEjb.setNamingResources(null);
}
}
/**
* Remove any message destination reference with the specified name.
*
* @param name Name of the message destination resource reference to remove
*/
public void removeMessageDestinationRef(String name) {
entries.remove(name);
MessageDestinationRef mdr;
synchronized (mdrs) {
mdr = mdrs.remove(name);
}
if (mdr != null) {
support.firePropertyChange("messageDestinationRef", mdr, null);
mdr.setNamingResources(null);
}
}
/**
* Remove a property change listener from this component.
*
* @param listener The listener to remove
*/
public void removePropertyChangeListener(PropertyChangeListener listener) {
support.removePropertyChangeListener(listener);
}
@Override
public void removeResource(String name) {
entries.remove(name);
ContextResource resource;
synchronized (resources) {
resource = resources.remove(name);
}
if (resource != null) {
support.firePropertyChange("resource", resource, null);
// De-register with JMX
if (resourceRequireExplicitRegistration) {
try {
MBeanUtils.destroyMBean(resource);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanDestroyFail", resource.getName()), e);
}
}
resource.setNamingResources(null);
}
}
/**
* Remove any resource environment reference with the specified name.
*
* @param name Name of the resource environment reference to remove
*/
public void removeResourceEnvRef(String name) {
entries.remove(name);
ContextResourceEnvRef resourceEnvRef;
synchronized (resourceEnvRefs) {
resourceEnvRef = resourceEnvRefs.remove(name);
}
if (resourceEnvRef != null) {
support.firePropertyChange("resourceEnvRef", resourceEnvRef, null);
resourceEnvRef.setNamingResources(null);
}
}
@Override
public void removeResourceLink(String name) {
entries.remove(name);
ContextResourceLink resourceLink;
synchronized (resourceLinks) {
resourceLink = resourceLinks.remove(name);
}
if (resourceLink != null) {
support.firePropertyChange("resourceLink", resourceLink, null);
// De-register with JMX
if (resourceRequireExplicitRegistration) {
try {
MBeanUtils.destroyMBean(resourceLink);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanDestroyFail", resourceLink.getName()), e);
}
}
resourceLink.setNamingResources(null);
}
}
/**
* Remove any web service reference with the specified name.
*
* @param name Name of the web service reference to remove
*/
public void removeService(String name) {
entries.remove(name);
ContextService service;
synchronized (services) {
service = services.remove(name);
}
if (service != null) {
support.firePropertyChange("service", service, null);
service.setNamingResources(null);
}
}
// ------------------------------------------------------- Lifecycle methods
@Override
protected void initInternal() throws LifecycleException {
super.initInternal();
// Set this before we register currently known naming resources to avoid
// timing issues. Duplication registration is not an issue.
resourceRequireExplicitRegistration = true;
for (ContextResource cr : resources.values()) {
try {
MBeanUtils.createMBean(cr);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanCreateFail", cr.getName()), e);
}
}
for (ContextEnvironment ce : envs.values()) {
try {
MBeanUtils.createMBean(ce);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanCreateFail", ce.getName()), e);
}
}
for (ContextResourceLink crl : resourceLinks.values()) {
try {
MBeanUtils.createMBean(crl);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanCreateFail", crl.getName()), e);
}
}
}
@Override
protected void startInternal() throws LifecycleException {
fireLifecycleEvent(CONFIGURE_START_EVENT, null);
setState(LifecycleState.STARTING);
}
@Override
protected void stopInternal() throws LifecycleException {
cleanUp();
setState(LifecycleState.STOPPING);
fireLifecycleEvent(CONFIGURE_STOP_EVENT, null);
}
/**
* Close those resources that an explicit close may help clean-up faster.
*/
private void cleanUp() {
if (resources.isEmpty()) {
return;
}
javax.naming.Context ctxt;
try {
if (container instanceof Server) {
ctxt = ((Server) container).getGlobalNamingContext();
} else {
ctxt = ContextBindings.getClassLoader();
ctxt = (javax.naming.Context) ctxt.lookup("comp/env");
}
} catch (NamingException e) {
log.warn(sm.getString("namingResources.cleanupNoContext", container), e);
return;
}
for (ContextResource cr : resources.values()) {
if (cr.getSingleton()) {
String closeMethod = cr.getCloseMethod();
if (closeMethod != null && !closeMethod.isEmpty()) {
String name = cr.getName();
Object resource;
try {
resource = ctxt.lookup(name);
} catch (NamingException e) {
log.warn(sm.getString("namingResources.cleanupNoResource", cr.getName(), container), e);
continue;
}
cleanUp(resource, name, closeMethod);
}
}
}
}
/**
* Clean up a resource by calling the defined close method. For example, closing a database connection pool will
* close it's open connections. This will happen on GC but that leaves db connections open that may cause issues.
*
* @param resource The resource to close.
*/
private void cleanUp(Object resource, String name, String closeMethod) {
// Look for a zero-arg close() method
Method m;
try {
m = resource.getClass().getMethod(closeMethod, (Class<?>[]) null);
} catch (SecurityException e) {
log.debug(sm.getString("namingResources.cleanupCloseSecurity", closeMethod, name, container), e);
return;
} catch (NoSuchMethodException e) {
log.debug(sm.getString("namingResources.cleanupNoClose", name, container, closeMethod), e);
return;
}
try {
m.invoke(resource, (Object[]) null);
} catch (IllegalArgumentException | IllegalAccessException e) {
log.warn(sm.getString("namingResources.cleanupCloseFailed", closeMethod, name, container), e);
} catch (InvocationTargetException e) {
Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
ExceptionUtils.handleThrowable(t);
log.warn(sm.getString("namingResources.cleanupCloseFailed", closeMethod, name, container), t);
}
}
@Override
protected void destroyInternal() throws LifecycleException {
// Set this before we de-register currently known naming resources to
// avoid timing issues. Duplication de-registration is not an issue.
resourceRequireExplicitRegistration = false;
// Destroy in reverse order to create, although it should not matter
for (ContextResourceLink crl : resourceLinks.values()) {
try {
MBeanUtils.destroyMBean(crl);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanDestroyFail", crl.getName()), e);
}
}
for (ContextEnvironment ce : envs.values()) {
try {
MBeanUtils.destroyMBean(ce);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanDestroyFail", ce.getName()), e);
}
}
for (ContextResource cr : resources.values()) {
try {
MBeanUtils.destroyMBean(cr);
} catch (Exception e) {
log.warn(sm.getString("namingResources.mbeanDestroyFail", cr.getName()), e);
}
}
super.destroyInternal();
}
@Override
protected String getDomainInternal() {
// Use the same domain as our associated container if we have one
Object c = getContainer();
if (c instanceof JmxEnabled) {
return ((JmxEnabled) c).getDomain();
}
return null;
}
@Override
protected String getObjectNameKeyProperties() {
Object c = getContainer();
if (c instanceof Container) {
return "type=NamingResources" + ((Container) c).getMBeanKeyProperties();
}
// Server or just unknown
return "type=NamingResources";
}
/**
* Checks that the configuration of the type for the specified resource is consistent with any injection targets and
* if the type is not specified, tries to configure the type based on the injection targets
*
* @param resource The resource to check
*
* @return <code>true</code> if the type for the resource is now valid (if previously <code>null</code> this means
* it is now set) or <code>false</code> if the current resource type is inconsistent with the injection
* targets and/or cannot be determined
*/
private boolean checkResourceType(ResourceBase resource) {
if (!(container instanceof Context context)) {
// Only Context's will have injection targets
return true;
}
if (resource.getInjectionTargets() == null || resource.getInjectionTargets().isEmpty()) {
// No injection targets so use the defined type for the resource
return true;
}
String typeName = resource.getType();
Class<?> typeClass = null;
if (typeName != null) {
typeClass = Introspection.loadClass(context, typeName);
if (typeClass == null) {
// Can't load the type - will trigger a failure later so don't
// fail here
return true;
}
}
Class<?> compatibleClass = getCompatibleType(context, resource, typeClass);
if (compatibleClass == null) {
// Indicates that a compatible type could not be identified that
// worked for all injection targets
return false;
}
resource.setType(compatibleClass.getCanonicalName());
return true;
}
private Class<?> getCompatibleType(Context context, ResourceBase resource, Class<?> typeClass) {
Class<?> result = null;
for (InjectionTarget injectionTarget : resource.getInjectionTargets()) {
Class<?> clazz = Introspection.loadClass(context, injectionTarget.getTargetClass());
if (clazz == null) {
// Can't load class - therefore ignore this target
continue;
}
// Look for a match
String targetName = injectionTarget.getTargetName();
// Look for a setter match first
Class<?> targetType = getSetterType(clazz, targetName);
if (targetType == null) {
// Try a field match if no setter match
targetType = getFieldType(clazz, targetName);
}
if (targetType == null) {
// No match - ignore this injection target
continue;
}
targetType = Introspection.convertPrimitiveType(targetType);
if (typeClass == null) {
// Need to find a common type amongst the injection targets
if (result == null) {
result = targetType;
} else if (targetType.isAssignableFrom(result)) {
// NO-OP - This will work
} else if (result.isAssignableFrom(targetType)) {
// Need to use more specific type
result = targetType;
} else {
// Incompatible types
return null;
}
} else {
// Each injection target needs to be consistent with the defined
// type
if (targetType.isAssignableFrom(typeClass)) {
result = typeClass;
} else {
// Incompatible types
return null;
}
}
}
return result;
}
private Class<?> getSetterType(Class<?> clazz, String name) {
for (Method method : clazz.getDeclaredMethods()) {
if (Introspection.isValidSetter(method) && Introspection.getPropertyName(method).equals(name)) {
return method.getParameterTypes()[0];
}
}
return null;
}
private Class<?> getFieldType(Class<?> clazz, String name) {
for (Field field : clazz.getDeclaredFields()) {
if (field.getName().equals(name)) {
return field.getType();
}
}
return null;
}
}
|
googleapis/google-cloud-java | 36,213 | java-bigqueryreservation/proto-google-cloud-bigqueryreservation-v1/src/main/java/com/google/cloud/bigquery/reservation/v1/SearchAllAssignmentsRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/bigquery/reservation/v1/reservation.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.bigquery.reservation.v1;
/**
*
*
* <pre>
* The request for
* [ReservationService.SearchAllAssignments][google.cloud.bigquery.reservation.v1.ReservationService.SearchAllAssignments].
* Note: "bigquery.reservationAssignments.search" permission is required on the
* related assignee.
* </pre>
*
* Protobuf type {@code google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest}
*/
public final class SearchAllAssignmentsRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest)
SearchAllAssignmentsRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use SearchAllAssignmentsRequest.newBuilder() to construct.
private SearchAllAssignmentsRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SearchAllAssignmentsRequest() {
parent_ = "";
query_ = "";
pageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new SearchAllAssignmentsRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.bigquery.reservation.v1.ReservationProto
.internal_static_google_cloud_bigquery_reservation_v1_SearchAllAssignmentsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.bigquery.reservation.v1.ReservationProto
.internal_static_google_cloud_bigquery_reservation_v1_SearchAllAssignmentsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest.class,
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest.Builder.class);
}
public static final int PARENT_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The resource name with location (project name could be the
* wildcard '-'), e.g.:
* `projects/-/locations/US`.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
@java.lang.Override
public java.lang.String getParent() {
java.lang.Object ref = parent_;
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();
parent_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The resource name with location (project name could be the
* wildcard '-'), e.g.:
* `projects/-/locations/US`.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
@java.lang.Override
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int QUERY_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object query_ = "";
/**
*
*
* <pre>
* Please specify resource name as assignee in the query.
*
* Examples:
*
* * `assignee=projects/myproject`
* * `assignee=folders/123`
* * `assignee=organizations/456`
* </pre>
*
* <code>string query = 2;</code>
*
* @return The query.
*/
@java.lang.Override
public java.lang.String getQuery() {
java.lang.Object ref = query_;
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();
query_ = s;
return s;
}
}
/**
*
*
* <pre>
* Please specify resource name as assignee in the query.
*
* Examples:
*
* * `assignee=projects/myproject`
* * `assignee=folders/123`
* * `assignee=organizations/456`
* </pre>
*
* <code>string query = 2;</code>
*
* @return The bytes for query.
*/
@java.lang.Override
public com.google.protobuf.ByteString getQueryBytes() {
java.lang.Object ref = query_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
query_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int PAGE_SIZE_FIELD_NUMBER = 3;
private int pageSize_ = 0;
/**
*
*
* <pre>
* The maximum number of items to return per page.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
public static final int PAGE_TOKEN_FIELD_NUMBER = 4;
@SuppressWarnings("serial")
private volatile java.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* The next_page_token value returned from a previous List request, if any.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The pageToken.
*/
@java.lang.Override
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
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();
pageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* The next_page_token value returned from a previous List request, if any.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The bytes for pageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(query_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, query_);
}
if (pageSize_ != 0) {
output.writeInt32(3, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, pageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(query_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, query_);
}
if (pageSize_ != 0) {
size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, pageSize_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, pageToken_);
}
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.bigquery.reservation.v1.SearchAllAssignmentsRequest)) {
return super.equals(obj);
}
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest other =
(com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest) obj;
if (!getParent().equals(other.getParent())) return false;
if (!getQuery().equals(other.getQuery())) return false;
if (getPageSize() != other.getPageSize()) return false;
if (!getPageToken().equals(other.getPageToken())) 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();
hash = (37 * hash) + PARENT_FIELD_NUMBER;
hash = (53 * hash) + getParent().hashCode();
hash = (37 * hash) + QUERY_FIELD_NUMBER;
hash = (53 * hash) + getQuery().hashCode();
hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER;
hash = (53 * hash) + getPageSize();
hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest 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.bigquery.reservation.v1.SearchAllAssignmentsRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest 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.bigquery.reservation.v1.SearchAllAssignmentsRequest parseFrom(
byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest 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.bigquery.reservation.v1.SearchAllAssignmentsRequest
parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest
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.bigquery.reservation.v1.SearchAllAssignmentsRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest 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.bigquery.reservation.v1.SearchAllAssignmentsRequest 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;
}
/**
*
*
* <pre>
* The request for
* [ReservationService.SearchAllAssignments][google.cloud.bigquery.reservation.v1.ReservationService.SearchAllAssignments].
* Note: "bigquery.reservationAssignments.search" permission is required on the
* related assignee.
* </pre>
*
* Protobuf type {@code google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest)
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.bigquery.reservation.v1.ReservationProto
.internal_static_google_cloud_bigquery_reservation_v1_SearchAllAssignmentsRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.bigquery.reservation.v1.ReservationProto
.internal_static_google_cloud_bigquery_reservation_v1_SearchAllAssignmentsRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest.class,
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest.Builder.class);
}
// Construct using
// com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
parent_ = "";
query_ = "";
pageSize_ = 0;
pageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.bigquery.reservation.v1.ReservationProto
.internal_static_google_cloud_bigquery_reservation_v1_SearchAllAssignmentsRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest
getDefaultInstanceForType() {
return com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest
.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest build() {
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest buildPartial() {
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest result =
new com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.parent_ = parent_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.query_ = query_;
}
if (((from_bitField0_ & 0x00000004) != 0)) {
result.pageSize_ = pageSize_;
}
if (((from_bitField0_ & 0x00000008) != 0)) {
result.pageToken_ = pageToken_;
}
}
@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.bigquery.reservation.v1.SearchAllAssignmentsRequest) {
return mergeFrom(
(com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(
com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest other) {
if (other
== com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest
.getDefaultInstance()) return this;
if (!other.getParent().isEmpty()) {
parent_ = other.parent_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getQuery().isEmpty()) {
query_ = other.query_;
bitField0_ |= 0x00000002;
onChanged();
}
if (other.getPageSize() != 0) {
setPageSize(other.getPageSize());
}
if (!other.getPageToken().isEmpty()) {
pageToken_ = other.pageToken_;
bitField0_ |= 0x00000008;
onChanged();
}
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 10:
{
parent_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
query_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 24:
{
pageSize_ = input.readInt32();
bitField0_ |= 0x00000004;
break;
} // case 24
case 34:
{
pageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000008;
break;
} // case 34
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.lang.Object parent_ = "";
/**
*
*
* <pre>
* Required. The resource name with location (project name could be the
* wildcard '-'), e.g.:
* `projects/-/locations/US`.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The parent.
*/
public java.lang.String getParent() {
java.lang.Object ref = parent_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
parent_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The resource name with location (project name could be the
* wildcard '-'), e.g.:
* `projects/-/locations/US`.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for parent.
*/
public com.google.protobuf.ByteString getParentBytes() {
java.lang.Object ref = parent_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
parent_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The resource name with location (project name could be the
* wildcard '-'), e.g.:
* `projects/-/locations/US`.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The parent to set.
* @return This builder for chaining.
*/
public Builder setParent(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource name with location (project name could be the
* wildcard '-'), e.g.:
* `projects/-/locations/US`.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearParent() {
parent_ = getDefaultInstance().getParent();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource name with location (project name could be the
* wildcard '-'), e.g.:
* `projects/-/locations/US`.
* </pre>
*
* <code>
* string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for parent to set.
* @return This builder for chaining.
*/
public Builder setParentBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
parent_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object query_ = "";
/**
*
*
* <pre>
* Please specify resource name as assignee in the query.
*
* Examples:
*
* * `assignee=projects/myproject`
* * `assignee=folders/123`
* * `assignee=organizations/456`
* </pre>
*
* <code>string query = 2;</code>
*
* @return The query.
*/
public java.lang.String getQuery() {
java.lang.Object ref = query_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
query_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Please specify resource name as assignee in the query.
*
* Examples:
*
* * `assignee=projects/myproject`
* * `assignee=folders/123`
* * `assignee=organizations/456`
* </pre>
*
* <code>string query = 2;</code>
*
* @return The bytes for query.
*/
public com.google.protobuf.ByteString getQueryBytes() {
java.lang.Object ref = query_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
query_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Please specify resource name as assignee in the query.
*
* Examples:
*
* * `assignee=projects/myproject`
* * `assignee=folders/123`
* * `assignee=organizations/456`
* </pre>
*
* <code>string query = 2;</code>
*
* @param value The query to set.
* @return This builder for chaining.
*/
public Builder setQuery(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
query_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Please specify resource name as assignee in the query.
*
* Examples:
*
* * `assignee=projects/myproject`
* * `assignee=folders/123`
* * `assignee=organizations/456`
* </pre>
*
* <code>string query = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearQuery() {
query_ = getDefaultInstance().getQuery();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Please specify resource name as assignee in the query.
*
* Examples:
*
* * `assignee=projects/myproject`
* * `assignee=folders/123`
* * `assignee=organizations/456`
* </pre>
*
* <code>string query = 2;</code>
*
* @param value The bytes for query to set.
* @return This builder for chaining.
*/
public Builder setQueryBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
query_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
private int pageSize_;
/**
*
*
* <pre>
* The maximum number of items to return per page.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @return The pageSize.
*/
@java.lang.Override
public int getPageSize() {
return pageSize_;
}
/**
*
*
* <pre>
* The maximum number of items to return per page.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @param value The pageSize to set.
* @return This builder for chaining.
*/
public Builder setPageSize(int value) {
pageSize_ = value;
bitField0_ |= 0x00000004;
onChanged();
return this;
}
/**
*
*
* <pre>
* The maximum number of items to return per page.
* </pre>
*
* <code>int32 page_size = 3;</code>
*
* @return This builder for chaining.
*/
public Builder clearPageSize() {
bitField0_ = (bitField0_ & ~0x00000004);
pageSize_ = 0;
onChanged();
return this;
}
private java.lang.Object pageToken_ = "";
/**
*
*
* <pre>
* The next_page_token value returned from a previous List request, if any.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The pageToken.
*/
public java.lang.String getPageToken() {
java.lang.Object ref = pageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
pageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The next_page_token value returned from a previous List request, if any.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return The bytes for pageToken.
*/
public com.google.protobuf.ByteString getPageTokenBytes() {
java.lang.Object ref = pageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
pageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The next_page_token value returned from a previous List request, if any.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @param value The pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
pageToken_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
/**
*
*
* <pre>
* The next_page_token value returned from a previous List request, if any.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @return This builder for chaining.
*/
public Builder clearPageToken() {
pageToken_ = getDefaultInstance().getPageToken();
bitField0_ = (bitField0_ & ~0x00000008);
onChanged();
return this;
}
/**
*
*
* <pre>
* The next_page_token value returned from a previous List request, if any.
* </pre>
*
* <code>string page_token = 4;</code>
*
* @param value The bytes for pageToken to set.
* @return This builder for chaining.
*/
public Builder setPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
pageToken_ = value;
bitField0_ |= 0x00000008;
onChanged();
return this;
}
@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.bigquery.reservation.v1.SearchAllAssignmentsRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest)
private static final com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest
DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest();
}
public static com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest
getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<SearchAllAssignmentsRequest> PARSER =
new com.google.protobuf.AbstractParser<SearchAllAssignmentsRequest>() {
@java.lang.Override
public SearchAllAssignmentsRequest 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<SearchAllAssignmentsRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SearchAllAssignmentsRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.bigquery.reservation.v1.SearchAllAssignmentsRequest
getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
openjdk/jdk8 | 36,443 | jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/xmlschema/SimpleTypeBuilder.java | /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.tools.internal.xjc.reader.xmlschema;
import java.io.StringWriter;
import java.math.BigInteger;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import javax.activation.MimeTypeParseException;
import javax.xml.bind.DatatypeConverter;
import com.sun.codemodel.internal.JJavaName;
import com.sun.codemodel.internal.util.JavadocEscapeWriter;
import com.sun.xml.internal.bind.v2.WellKnownNamespace;
import com.sun.tools.internal.xjc.ErrorReceiver;
import com.sun.tools.internal.xjc.model.CBuiltinLeafInfo;
import com.sun.tools.internal.xjc.model.CClassInfo;
import com.sun.tools.internal.xjc.model.CClassInfoParent;
import com.sun.tools.internal.xjc.model.CClassRef;
import com.sun.tools.internal.xjc.model.CEnumConstant;
import com.sun.tools.internal.xjc.model.CEnumLeafInfo;
import com.sun.tools.internal.xjc.model.CNonElement;
import com.sun.tools.internal.xjc.model.Model;
import com.sun.tools.internal.xjc.model.TypeUse;
import com.sun.tools.internal.xjc.model.TypeUseFactory;
import com.sun.tools.internal.xjc.reader.Const;
import com.sun.tools.internal.xjc.reader.Ring;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIEnum;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIEnumMember;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIProperty;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BindInfo;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.EnumMemberMode;
import com.sun.tools.internal.xjc.util.MimeTypeRange;
import static com.sun.xml.internal.bind.v2.WellKnownNamespace.XML_MIME_URI;
import com.sun.xml.internal.bind.v2.runtime.SwaRefAdapterMarker;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSComponent;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSListSimpleType;
import com.sun.xml.internal.xsom.XSRestrictionSimpleType;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSUnionSimpleType;
import com.sun.xml.internal.xsom.XSVariety;
import com.sun.xml.internal.xsom.impl.util.SchemaWriter;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
/**
* Builds {@link TypeUse} from simple types.
*
* <p>
* This code consists of two main portions. The {@link #compose(XSSimpleType)} method
* and {@link #composer} forms an outer cycle, which gradually ascends the type
* inheritance chain until it finds the suitable binding. When it does this
* {@link #initiatingType} is set to the type which started binding, so that we can refer
* to the actual constraint facets and such that are applicable on the type.
*
* <p>
* For each intermediate type in the chain, the {@link #find(XSSimpleType)} method
* is used to find the binding on that type, sine the outer loop is doing the ascending,
* this method only sees if the current type has some binding available.
*
* <p>
* There is at least one ugly code that you need to aware of
* when you are modifying the code. See the documentation
* about <a href="package.html#stref_cust">
* "simple type customization at the point of reference."</a>
*
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public final class SimpleTypeBuilder extends BindingComponent {
protected final BGMBuilder builder = Ring.get(BGMBuilder.class);
private final Model model = Ring.get(Model.class);
/**
* The component that is refering to the simple type
* which we are building. This is ugly but necessary
* to support the customization of simple types at
* its point of reference. See my comment at the header
* of this class for details.
*
* UGLY: Implemented as a Stack of XSComponent to fix a bug
*/
public final Stack<XSComponent> refererStack = new Stack<XSComponent>();
/**
* Records what xmime:expectedContentTypes annotations we honored and processed,
* so that we can later check if the user had these annotations in the places
* where we didn't anticipate them.
*/
private final Set<XSComponent> acknowledgedXmimeContentTypes = new HashSet<XSComponent>();
/**
* The type that was originally passed to this {@link SimpleTypeBuilder#build(XSSimpleType)}.
* Never null.
*/
private XSSimpleType initiatingType;
/** {@link TypeUse}s for the built-in types. Read-only. */
public static final Map<String,TypeUse> builtinConversions = new HashMap<String,TypeUse>();
/**
* Entry point from outside. Builds a BGM type expression
* from a simple type schema component.
*
* @param type
* the simple type to be bound.
*/
public TypeUse build( XSSimpleType type ) {
XSSimpleType oldi = initiatingType;
this.initiatingType = type;
TypeUse e = checkRefererCustomization(type);
if(e==null)
e = compose(type);
initiatingType = oldi;
return e;
}
/**
* A version of the {@link #build(XSSimpleType)} method
* used to bind the definition of a class generated from
* the given simple type.
*/
public TypeUse buildDef( XSSimpleType type ) {
XSSimpleType oldi = initiatingType;
this.initiatingType = type;
TypeUse e = type.apply(composer);
initiatingType = oldi;
return e;
}
/**
* Returns a javaType customization specified to the referer, if present.
* @return can be null.
*/
private BIConversion getRefererCustomization() {
BindInfo info = builder.getBindInfo(getReferer());
BIProperty prop = info.get(BIProperty.class);
if(prop==null) return null;
return prop.getConv();
}
public XSComponent getReferer() {
return refererStack.peek();
}
/**
* Checks if the referer has a conversion customization or not.
* If it does, use it to bind this simple type. Otherwise
* return null;
*/
private TypeUse checkRefererCustomization( XSSimpleType type ) {
// assertion check. referer must be set properly
// before the build method is called.
// since the handling of the simple type point-of-reference
// customization is very error prone, it deserves a strict
// assertion check.
// UGLY CODE WARNING
XSComponent top = getReferer();
if( top instanceof XSElementDecl ) {
// if the parent is element type, its content type must be us.
XSElementDecl eref = (XSElementDecl)top;
assert eref.getType()==type;
// for elements, you can't use <property>,
// so we allow javaType to appear directly.
BindInfo info = builder.getBindInfo(top);
BIConversion conv = info.get(BIConversion.class);
if(conv!=null) {
conv.markAsAcknowledged();
// the conversion is given.
return conv.getTypeUse(type);
}
detectJavaTypeCustomization();
} else
if( top instanceof XSAttributeDecl ) {
XSAttributeDecl aref = (XSAttributeDecl)top;
assert aref.getType()==type;
detectJavaTypeCustomization();
} else
if( top instanceof XSComplexType ) {
XSComplexType tref = (XSComplexType)top;
assert tref.getBaseType()==type || tref.getContentType()==type;
detectJavaTypeCustomization();
} else
if( top == type ) {
// this means the simple type is built by itself and
// not because it's referenced by something.
} else
// unexpected referer type.
assert false;
// now we are certain that the referer is OK.
// see if it has a conversion customization.
BIConversion conv = getRefererCustomization();
if(conv!=null) {
conv.markAsAcknowledged();
// the conversion is given.
return conv.getTypeUse(type);
} else
// not found
return null;
}
/**
* Detect "javaType" customizations placed directly on simple types, rather
* than being enclosed by "property" and "baseType" customizations (see
* sec 6.8.1 of the spec).
*
* Report an error if any exist.
*/
private void detectJavaTypeCustomization() {
BindInfo info = builder.getBindInfo(getReferer());
BIConversion conv = info.get(BIConversion.class);
if( conv != null ) {
// ack this conversion to prevent further error messages
conv.markAsAcknowledged();
// report the error
getErrorReporter().error( conv.getLocation(),
Messages.ERR_UNNESTED_JAVATYPE_CUSTOMIZATION_ON_SIMPLETYPE );
}
}
/**
* Recursively decend the type inheritance chain to find a binding.
*/
TypeUse compose( XSSimpleType t ) {
TypeUse e = find(t);
if(e!=null) return e;
return t.apply(composer);
}
public final XSSimpleTypeFunction<TypeUse> composer = new XSSimpleTypeFunction<TypeUse>() {
public TypeUse listSimpleType(XSListSimpleType type) {
// bind item type individually and then compose them into a list
// facets on the list shouldn't be taken account when binding item types,
// so weed to call build(), not compose().
XSSimpleType itemType = type.getItemType();
refererStack.push(itemType);
TypeUse tu = TypeUseFactory.makeCollection(build(type.getItemType()));
refererStack.pop();
return tu;
}
public TypeUse unionSimpleType(XSUnionSimpleType type) {
boolean isCollection = false;
for( int i=0; i<type.getMemberSize(); i++ )
if(type.getMember(i).getVariety()==XSVariety.LIST || type.getMember(i).getVariety()==XSVariety.UNION) {
isCollection = true;
break;
}
TypeUse r = CBuiltinLeafInfo.STRING;
if(isCollection)
r = TypeUseFactory.makeCollection(r);
return r;
}
public TypeUse restrictionSimpleType(XSRestrictionSimpleType type) {
// just process the base type.
return compose(type.getSimpleBaseType());
}
};
/**
* Checks if there's any binding available on the given type.
*
* @return
* null if not (which causes the {@link #compose(XSSimpleType)} method
* to do ascending.
*/
private TypeUse find( XSSimpleType type ) {
TypeUse r;
boolean noAutoEnum = false;
// check for user specified conversion
BindInfo info = builder.getBindInfo(type);
BIConversion conv = info.get(BIConversion.class);
if( conv!=null ) {
// a conversion was found
conv.markAsAcknowledged();
return conv.getTypeUse(type);
}
// look for enum customization, which is another user specified conversion
BIEnum en = info.get(BIEnum.class);
if( en!=null ) {
en.markAsAcknowledged();
if(!en.isMapped()) {
noAutoEnum = true;
} else {
// if an enum customization is specified, make sure
// the type is OK
if( !canBeMappedToTypeSafeEnum(type) ) {
getErrorReporter().error( en.getLocation(),
Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM );
getErrorReporter().error( type.getLocator(),
Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM_LOCATION );
// recover by ignoring this customization
return null;
}
// reference?
if(en.ref!=null) {
if(!JJavaName.isFullyQualifiedClassName(en.ref)) {
Ring.get(ErrorReceiver.class).error( en.getLocation(),
Messages.format(Messages.ERR_INCORRECT_CLASS_NAME, en.ref) );
// recover by ignoring @ref
return null;
}
return new CClassRef(model, type, en, info.toCustomizationList() );
}
// list and union cannot be mapped to a type-safe enum,
// so in this stage we can safely cast it to XSRestrictionSimpleType
return bindToTypeSafeEnum( (XSRestrictionSimpleType)type,
en.className, en.javadoc, en.members,
getEnumMemberMode().getModeWithEnum(),
en.getLocation() );
}
}
// if the type is built in, look for the default binding
if(type.getTargetNamespace().equals(WellKnownNamespace.XML_SCHEMA)) {
String name = type.getName();
if(name!=null) {
r = lookupBuiltin(name);
if(r!=null)
return r;
}
}
// also check for swaRef
if(type.getTargetNamespace().equals(WellKnownNamespace.SWA_URI)) {
String name = type.getName();
if(name!=null && name.equals("swaRef"))
return CBuiltinLeafInfo.STRING.makeAdapted(SwaRefAdapterMarker.class,false);
}
// see if this type should be mapped to a type-safe enumeration by default.
// if so, built a EnumXDucer from it and return it.
if(type.isRestriction() && !noAutoEnum) {
XSRestrictionSimpleType rst = type.asRestriction();
if(shouldBeMappedToTypeSafeEnumByDefault(rst)) {
r = bindToTypeSafeEnum(rst,null,null, Collections.<String, BIEnumMember>emptyMap(),
getEnumMemberMode(),null);
if(r!=null)
return r;
}
}
return (CNonElement)getClassSelector()._bindToClass(type,null,false);
}
private static Set<XSRestrictionSimpleType> reportedEnumMemberSizeWarnings;
/**
* Returns true if a type-safe enum should be created from
* the given simple type by default without an explicit <jaxb:enum> customization.
*/
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {
// if not, there will be a problem wrt the class name of this type safe enum type.
if( type.isLocal() ) return false;
// if redefined, we should map the new definition, not the old one.
if( type.getRedefinedBy()!=null ) return false;
List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
if( facets.isEmpty() )
// if the type itself doesn't have the enumeration facet,
// it won't be mapped to a type-safe enum.
return false;
if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
// if there are too many facets, it's not very useful
// produce warning when simple type is not mapped to enum
// see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711
if(reportedEnumMemberSizeWarnings == null)
reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();
if(!reportedEnumMemberSizeWarnings.contains(type)) {
getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());
reportedEnumMemberSizeWarnings.add(type);
}
return false;
}
if( !canBeMappedToTypeSafeEnum(type) )
// we simply can't map this to an enumeration
return false;
// check for collisions among constant names. if a collision will happen,
// don't try to bind it to an enum.
// return true only when this type is derived from one of the "enum base type".
for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
return true;
return false;
}
private static final Set<String> builtinTypeSafeEnumCapableTypes;
static {
Set<String> s = new HashSet<String>();
// see a bullet of 6.5.1 of the spec.
String[] typeNames = new String[] {
"string", "boolean", "float", "decimal", "double", "anyURI"
};
s.addAll(Arrays.asList(typeNames));
builtinTypeSafeEnumCapableTypes = Collections.unmodifiableSet(s);
}
/**
* Returns true if the given simple type can be mapped to a
* type-safe enum class.
*
* <p>
* JAXB spec places a restrictrion as to what type can be
* mapped to a type-safe enum. This method enforces this
* constraint.
*/
public static boolean canBeMappedToTypeSafeEnum( XSSimpleType type ) {
do {
if( WellKnownNamespace.XML_SCHEMA.equals(type.getTargetNamespace()) ) {
// type must be derived from one of these types
String localName = type.getName();
if( localName!=null ) {
if( localName.equals("anySimpleType") )
return false; // catch all case
if( localName.equals("ID") || localName.equals("IDREF") )
return false; // not ID/IDREF
// other allowed list
if( builtinTypeSafeEnumCapableTypes.contains(localName) )
return true;
}
}
type = type.getSimpleBaseType();
} while( type!=null );
return false;
}
/**
* Builds a type-safe enum conversion from a simple type
* with enumeration facets.
*
* @param className
* The class name of the type-safe enum. Or null to
* create a default name.
* @param javadoc
* Additional javadoc that will be added at the beginning of the
* class, or null if none is necessary.
* @param members
* A map from enumeration values (as String) to BIEnumMember objects.
* if some of the value names need to be overrided.
* Cannot be null, but the map may not contain entries
* for all enumeration values.
* @param loc
* The source location where the above customizations are
* specified, or null if none is available.
*/
private TypeUse bindToTypeSafeEnum( XSRestrictionSimpleType type,
String className, String javadoc, Map<String,BIEnumMember> members,
EnumMemberMode mode, Locator loc ) {
if( loc==null ) // use the location of the simple type as the default
loc = type.getLocator();
if( className==null ) {
// infer the class name. For this to be possible,
// the simple type must be a global one.
if( !type.isGlobal() ) {
getErrorReporter().error( loc, Messages.ERR_NO_ENUM_NAME_AVAILABLE );
// recover by returning a meaningless conversion
return CBuiltinLeafInfo.STRING;
}
className = type.getName();
}
// we apply name conversion in any case
className = builder.deriveName(className,type);
{// compute Javadoc
StringWriter out = new StringWriter();
SchemaWriter sw = new SchemaWriter(new JavadocEscapeWriter(out));
type.visit((XSVisitor)sw);
if(javadoc!=null) javadoc += "\n\n";
else javadoc = "";
javadoc += Messages.format( Messages.JAVADOC_HEADING, type.getName() )
+"\n<p>\n<pre>\n"+out.getBuffer()+"</pre>";
}
// build base type
refererStack.push(type.getSimpleBaseType());
TypeUse use = build(type.getSimpleBaseType());
refererStack.pop();
if(use.isCollection())
return null; // can't bind a list to enum constant
CNonElement baseDt = use.getInfo(); // for now just ignore that case
if(baseDt instanceof CClassInfo)
return null; // can't bind to an enum if the base is a class, since we don't have the value constrctor
// if the member names collide, re-generate numbered constant names.
XSFacet[] errorRef = new XSFacet[1];
List<CEnumConstant> memberList = buildCEnumConstants(type, false, members, errorRef);
if(memberList==null || checkMemberNameCollision(memberList)!=null) {
switch(mode) {
case SKIP:
// abort
return null;
case ERROR:
// error
if(memberList==null) {
getErrorReporter().error( errorRef[0].getLocator(),
Messages.ERR_CANNOT_GENERATE_ENUM_NAME,
errorRef[0].getValue() );
} else {
CEnumConstant[] collision = checkMemberNameCollision(memberList);
getErrorReporter().error( collision[0].getLocator(),
Messages.ERR_ENUM_MEMBER_NAME_COLLISION,
collision[0].getName() );
getErrorReporter().error( collision[1].getLocator(),
Messages.ERR_ENUM_MEMBER_NAME_COLLISION_RELATED );
}
return null; // recover from error
case GENERATE:
// generate
memberList = buildCEnumConstants(type,true,members,null);
break;
}
}
if(memberList.isEmpty()) {
getErrorReporter().error( loc, Messages.ERR_NO_ENUM_FACET );
return null;
}
// use the name of the simple type as the name of the class.
CClassInfoParent scope;
if(type.isGlobal())
scope = new CClassInfoParent.Package(getClassSelector().getPackage(type.getTargetNamespace()));
else
scope = getClassSelector().getClassScope();
CEnumLeafInfo xducer = new CEnumLeafInfo( model, BGMBuilder.getName(type), scope,
className, baseDt, memberList, type,
builder.getBindInfo(type).toCustomizationList(), loc );
xducer.javadoc = javadoc;
BIConversion conv = new BIConversion.Static( type.getLocator(),xducer);
conv.markAsAcknowledged();
// attach this new conversion object to this simple type
// so that successive look up will use the same object.
builder.getOrCreateBindInfo(type).addDecl(conv);
return conv.getTypeUse(type);
}
/**
*
* @param errorRef
* if constant names couldn't be generated, return a reference to that enum facet.
* @return
* null if unable to generate names for some of the constants.
*/
private List<CEnumConstant> buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[] errorRef) {
List<CEnumConstant> memberList = new ArrayList<CEnumConstant>();
int idx=1;
Set<String> enums = new HashSet<String>(); // to avoid duplicates. See issue #366
for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) {
String name=null;
String mdoc=builder.getBindInfo(facet).getDocumentation();
if(!enums.add(facet.getValue().value))
continue; // ignore the 2nd occasion
if( needsToGenerateMemberName ) {
// generate names for all member names.
// this will even override names specified by the user. that's crazy.
name = "VALUE_"+(idx++);
} else {
String facetValue = facet.getValue().value;
BIEnumMember mem = members.get(facetValue);
if( mem==null )
// look at the one attached to the facet object
mem = builder.getBindInfo(facet).get(BIEnumMember.class);
if (mem!=null) {
name = mem.name;
if (mdoc == null) {
mdoc = mem.javadoc;
}
}
if(name==null) {
StringBuilder sb = new StringBuilder();
for( int i=0; i<facetValue.length(); i++) {
char ch = facetValue.charAt(i);
if(Character.isJavaIdentifierPart(ch))
sb.append(ch);
else
sb.append('_');
}
name = model.getNameConverter().toConstantName(sb.toString());
}
}
if(!JJavaName.isJavaIdentifier(name)) {
if(errorRef!=null) errorRef[0] = facet;
return null; // unable to generate a name
}
memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator()));
}
return memberList;
}
/**
* Returns non-null if {@link CEnumConstant}s have name collisions among them.
*
* @return
* if there's a collision, return two {@link CEnumConstant}s that collided.
* otherwise return null.
*/
private CEnumConstant[] checkMemberNameCollision( List<CEnumConstant> memberList ) {
Map<String,CEnumConstant> names = new HashMap<String,CEnumConstant>();
for (CEnumConstant c : memberList) {
CEnumConstant old = names.put(c.getName(),c);
if(old!=null)
// collision detected
return new CEnumConstant[]{old,c};
}
return null;
}
private EnumMemberMode getEnumMemberMode() {
return builder.getGlobalBinding().getEnumMemberMode();
}
private TypeUse lookupBuiltin( String typeLocalName ) {
if(typeLocalName.equals("integer") || typeLocalName.equals("long")) {
/*
attempt an optimization so that we can
improve the binding for types like this:
<simpleType>
<restriciton baseType="integer">
<maxInclusive value="100" />
</
</
... to int, not BigInteger.
*/
BigInteger xe = readFacet(XSFacet.FACET_MAXEXCLUSIVE,-1);
BigInteger xi = readFacet(XSFacet.FACET_MAXINCLUSIVE,0);
BigInteger max = min(xe,xi); // most restrictive one takes precedence
if(max!=null) {
BigInteger ne = readFacet(XSFacet.FACET_MINEXCLUSIVE,+1);
BigInteger ni = readFacet(XSFacet.FACET_MININCLUSIVE,0);
BigInteger min = max(ne,ni);
if(min!=null) {
if(min.compareTo(INT_MIN )>=0 && max.compareTo(INT_MAX )<=0)
typeLocalName = "int";
else
if(min.compareTo(LONG_MIN)>=0 && max.compareTo(LONG_MAX)<=0)
typeLocalName = "long";
}
}
} else
if(typeLocalName.equals("boolean") && isRestrictedTo0And1()) {
// this is seen in the SOAP schema and too common to ignore
return CBuiltinLeafInfo.BOOLEAN_ZERO_OR_ONE;
} else
if(typeLocalName.equals("base64Binary")) {
return lookupBinaryTypeBinding();
} else
if(typeLocalName.equals("anySimpleType")) {
if(getReferer() instanceof XSAttributeDecl || getReferer() instanceof XSSimpleType)
return CBuiltinLeafInfo.STRING;
else
return CBuiltinLeafInfo.ANYTYPE;
}
return builtinConversions.get(typeLocalName);
}
/**
* Decides the way xs:base64Binary binds.
*
* This method checks the expected media type.
*/
private TypeUse lookupBinaryTypeBinding() {
XSComponent referer = getReferer();
String emt = referer.getForeignAttribute(XML_MIME_URI, Const.EXPECTED_CONTENT_TYPES);
if(emt!=null) {
acknowledgedXmimeContentTypes.add(referer);
try {
// see http://www.xml.com/lpt/a/2004/07/21/dive.html
List<MimeTypeRange> types = MimeTypeRange.parseRanges(emt);
MimeTypeRange mt = MimeTypeRange.merge(types);
// see spec table I-1 in appendix I section 2.1.1 for bindings
if(mt.majorType.equalsIgnoreCase("image"))
return CBuiltinLeafInfo.IMAGE.makeMimeTyped(mt.toMimeType());
if(( mt.majorType.equalsIgnoreCase("application") || mt.majorType.equalsIgnoreCase("text"))
&& isXml(mt.subType))
return CBuiltinLeafInfo.XML_SOURCE.makeMimeTyped(mt.toMimeType());
if((mt.majorType.equalsIgnoreCase("text") && (mt.subType.equalsIgnoreCase("plain")) )) {
return CBuiltinLeafInfo.STRING.makeMimeTyped(mt.toMimeType());
}
return CBuiltinLeafInfo.DATA_HANDLER.makeMimeTyped(mt.toMimeType());
} catch (ParseException e) {
getErrorReporter().error( referer.getLocator(),
Messages.format(Messages.ERR_ILLEGAL_EXPECTED_MIME_TYPE,emt, e.getMessage()) );
// recover by using the default
} catch (MimeTypeParseException e) {
getErrorReporter().error( referer.getLocator(),
Messages.format(Messages.ERR_ILLEGAL_EXPECTED_MIME_TYPE,emt, e.getMessage()) );
}
}
// default
return CBuiltinLeafInfo.BASE64_BYTE_ARRAY;
}
public boolean isAcknowledgedXmimeContentTypes(XSComponent c) {
return acknowledgedXmimeContentTypes.contains(c);
}
/**
* Returns true if the specified sub-type is an XML type.
*/
private boolean isXml(String subType) {
return subType.equals("xml") || subType.endsWith("+xml");
}
/**
* Returns true if the {@link #initiatingType} is restricted
* to '0' and '1'. This logic is not complete, but it at least
* finds the such definition in SOAP @mustUnderstand.
*/
private boolean isRestrictedTo0And1() {
XSFacet pattern = initiatingType.getFacet(XSFacet.FACET_PATTERN);
if(pattern!=null) {
String v = pattern.getValue().value;
if(v.equals("0|1") || v.equals("1|0") || v.equals("\\d"))
return true;
}
XSFacet enumf = initiatingType.getFacet(XSFacet.FACET_ENUMERATION);
if(enumf!=null) {
String v = enumf.getValue().value;
if(v.equals("0") || v.equals("1"))
return true;
}
return false;
}
private BigInteger readFacet(String facetName,int offset) {
XSFacet me = initiatingType.getFacet(facetName);
if(me==null)
return null;
BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
if(offset!=0)
bi = bi.add(BigInteger.valueOf(offset));
return bi;
}
private BigInteger min(BigInteger a, BigInteger b) {
if(a==null) return b;
if(b==null) return a;
return a.min(b);
}
private BigInteger max(BigInteger a, BigInteger b) {
if(a==null) return b;
if(b==null) return a;
return a.max(b);
}
private static final BigInteger LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE);
private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
private static final BigInteger INT_MIN = BigInteger.valueOf(Integer.MIN_VALUE);
private static final BigInteger INT_MAX = BigInteger.valueOf(Integer.MAX_VALUE);
static {
// list of datatypes which have built-in conversions.
// note that although xs:token and xs:normalizedString are not
// specified in the spec, they need to be here because they
// have different whitespace normalization semantics.
Map<String,TypeUse> m = builtinConversions;
// TODO: this is so dumb
m.put("string", CBuiltinLeafInfo.STRING);
m.put("anyURI", CBuiltinLeafInfo.STRING);
m.put("boolean", CBuiltinLeafInfo.BOOLEAN);
// we'll also look at the expected media type, so don't just add this to the map
// m.put("base64Binary", CBuiltinLeafInfo.BASE64_BYTE_ARRAY);
m.put("hexBinary", CBuiltinLeafInfo.HEXBIN_BYTE_ARRAY);
m.put("float", CBuiltinLeafInfo.FLOAT);
m.put("decimal", CBuiltinLeafInfo.BIG_DECIMAL);
m.put("integer", CBuiltinLeafInfo.BIG_INTEGER);
m.put("long", CBuiltinLeafInfo.LONG);
m.put("unsignedInt", CBuiltinLeafInfo.LONG);
m.put("int", CBuiltinLeafInfo.INT);
m.put("unsignedShort", CBuiltinLeafInfo.INT);
m.put("short", CBuiltinLeafInfo.SHORT);
m.put("unsignedByte", CBuiltinLeafInfo.SHORT);
m.put("byte", CBuiltinLeafInfo.BYTE);
m.put("double", CBuiltinLeafInfo.DOUBLE);
m.put("QName", CBuiltinLeafInfo.QNAME);
m.put("NOTATION", CBuiltinLeafInfo.QNAME);
m.put("dateTime", CBuiltinLeafInfo.CALENDAR);
m.put("date", CBuiltinLeafInfo.CALENDAR);
m.put("time", CBuiltinLeafInfo.CALENDAR);
m.put("gYearMonth", CBuiltinLeafInfo.CALENDAR);
m.put("gYear", CBuiltinLeafInfo.CALENDAR);
m.put("gMonthDay", CBuiltinLeafInfo.CALENDAR);
m.put("gDay", CBuiltinLeafInfo.CALENDAR);
m.put("gMonth", CBuiltinLeafInfo.CALENDAR);
m.put("duration", CBuiltinLeafInfo.DURATION);
m.put("token", CBuiltinLeafInfo.TOKEN);
m.put("normalizedString",CBuiltinLeafInfo.NORMALIZED_STRING);
m.put("ID", CBuiltinLeafInfo.ID);
m.put("IDREF", CBuiltinLeafInfo.IDREF);
// TODO: handling dateTime, time, and date type
// String[] names = {
// "date", "dateTime", "time", "hexBinary" };
}
}
|
apache/fineract | 36,363 | integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.integrationtests.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.HashMap;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.models.GetGlobalConfigurationsResponse;
import org.apache.fineract.client.models.GlobalConfigurationPropertyData;
import org.apache.fineract.client.models.PutGlobalConfigurationsRequest;
import org.apache.fineract.client.models.PutGlobalConfigurationsResponse;
import org.apache.fineract.client.util.Calls;
import org.apache.fineract.client.util.JSON;
import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants;
import org.junit.jupiter.api.Assertions;
@SuppressWarnings({ "unused", "rawtypes" })
@Slf4j
@RequiredArgsConstructor
public class GlobalConfigurationHelper {
private static final Gson GSON = new JSON().getGson();
public GetGlobalConfigurationsResponse getAllGlobalConfigurations() {
log.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------");
return Calls.ok(FineractClientHelper.getFineractClient().globalConfigurations.retrieveConfiguration(false));
}
public GlobalConfigurationPropertyData getGlobalConfigurationByName(final String configName) {
log.info("------------------------ RETRIEVING GLOBAL CONFIGURATION BY NAME -------------------------");
return Calls.ok(FineractClientHelper.getFineractClient().globalConfigurations.retrieveOneByName(configName));
}
public GlobalConfigurationPropertyData getGlobalConfigurationById(final Long configId) {
log.info("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------");
return Calls.ok(FineractClientHelper.getFineractClient().globalConfigurations.retrieveOne3(configId));
}
// TODO: This is quite a bad pattern and adds a lot of time to individual test executions
public void resetAllDefaultGlobalConfigurations() {
GetGlobalConfigurationsResponse actualGlobalConfigurations = getAllGlobalConfigurations();
final ArrayList<HashMap> defaults = getAllDefaultGlobalConfigurations();
int changedNo = 0;
for (int i = 0; i < actualGlobalConfigurations.getGlobalConfiguration().size(); i++) {
HashMap defaultGlobalConfiguration = defaults.get(i);
GlobalConfigurationPropertyData actualGlobalConfiguration = actualGlobalConfigurations.getGlobalConfiguration().get(i);
if (!isMatching(defaultGlobalConfiguration, actualGlobalConfiguration)) {
/**
* Cannot update trapDoor global configurations because
* {@link org.apache.fineract.infrastructure.configuration.exception.GlobalConfigurationPropertyCannotBeModfied}
* will be thrown.
*/
if ((Boolean) defaultGlobalConfiguration.get("trapDoor")) {
continue;
}
// Currently only values and enabled flags are modified by the
// integration test suite.
// If any other column is modified by the integration test suite in
// the future, it needs to be reset here.
final String configName = (String) defaultGlobalConfiguration.get("name");
final Long configDefaultValue = (Long) defaultGlobalConfiguration.get("value");
updateGlobalConfiguration(configName, new PutGlobalConfigurationsRequest().value(configDefaultValue)
.enabled((Boolean) defaultGlobalConfiguration.get("enabled")));
changedNo++;
}
}
log.info("--------------------------------- UPDATED GLOBAL CONFIG ENTRY SIZE: {} ---------------------------------------------",
changedNo);
}
private static boolean isMatching(HashMap o1, GlobalConfigurationPropertyData o2) {
return o1.get("name").equals(o2.getName()) && o1.get("value").equals(o2.getValue()) && o1.get("enabled").equals(o2.getEnabled())
&& o1.get("trapDoor").equals(o2.getTrapDoor());
}
public void verifyAllDefaultGlobalConfigurations() {
ArrayList<HashMap> expectedGlobalConfigurations = getAllDefaultGlobalConfigurations();
GetGlobalConfigurationsResponse actualGlobalConfigurations = getAllGlobalConfigurations();
Assertions.assertEquals(59, expectedGlobalConfigurations.size());
Assertions.assertEquals(59, actualGlobalConfigurations.getGlobalConfiguration().size());
for (int i = 0; i < expectedGlobalConfigurations.size(); i++) {
HashMap expectedGlobalConfiguration = expectedGlobalConfigurations.get(i);
GlobalConfigurationPropertyData actualGlobalConfiguration = actualGlobalConfigurations.getGlobalConfiguration().get(i);
final String assertionFailedMessage = "Assertion failed for configName:<" + expectedGlobalConfiguration.get("name") + ">";
Assertions.assertEquals(expectedGlobalConfiguration.get("name"), actualGlobalConfiguration.getName(), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.getValue(), assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.getEnabled(),
assertionFailedMessage);
Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.getTrapDoor(),
assertionFailedMessage);
}
}
/**
* Helper method to get the current default instance data of the /configurations endpoint. Used to reset and verify
* that no global configuration affects state between integration tests.
*
* @see <a href= "https://issues.apache.org/jira/browse/FINERACT-722">FINERACT-722</a> This is a quick, fail fast
* and early implementation to resolve this issue. TODO: A more robust future solution would be isolating all
* integration test state using Spring Framework's integration test infrastructure for transaction commits and
* rollbacks.
*/
private static ArrayList<HashMap> getAllDefaultGlobalConfigurations() {
ArrayList<HashMap> defaults = new ArrayList<>();
HashMap<String, Object> makerCheckerDefault = new HashMap<>();
makerCheckerDefault.put("name", GlobalConfigurationConstants.MAKER_CHECKER);
makerCheckerDefault.put("value", 0L);
makerCheckerDefault.put("enabled", false);
makerCheckerDefault.put("trapDoor", false);
defaults.add(makerCheckerDefault);
HashMap<String, Object> amazonS3Default = new HashMap<>();
amazonS3Default.put("name", GlobalConfigurationConstants.AMAZON_S3);
amazonS3Default.put("value", 0L);
amazonS3Default.put("enabled", false);
amazonS3Default.put("trapDoor", false);
defaults.add(amazonS3Default);
HashMap<String, Object> rescheduleFuturePaymentsDefault = new HashMap<>();
rescheduleFuturePaymentsDefault.put("name", GlobalConfigurationConstants.RESCHEDULE_FUTURE_REPAYMENTS);
rescheduleFuturePaymentsDefault.put("value", 0L);
rescheduleFuturePaymentsDefault.put("enabled", true);
rescheduleFuturePaymentsDefault.put("trapDoor", false);
defaults.add(rescheduleFuturePaymentsDefault);
HashMap<String, Object> rescheduleRepaymentsOnHolidaysDefault = new HashMap<>();
rescheduleRepaymentsOnHolidaysDefault.put("id", 6);
rescheduleRepaymentsOnHolidaysDefault.put("name", GlobalConfigurationConstants.RESCHEDULE_REPAYMENTS_ON_HOLIDAYS);
rescheduleRepaymentsOnHolidaysDefault.put("value", 0L);
rescheduleRepaymentsOnHolidaysDefault.put("enabled", false);
rescheduleRepaymentsOnHolidaysDefault.put("trapDoor", false);
defaults.add(rescheduleRepaymentsOnHolidaysDefault);
HashMap<String, Object> allowTransactionsOnHolidayDefault = new HashMap<>();
allowTransactionsOnHolidayDefault.put("name", GlobalConfigurationConstants.ALLOW_TRANSACTIONS_ON_HOLIDAY);
allowTransactionsOnHolidayDefault.put("value", 0L);
allowTransactionsOnHolidayDefault.put("enabled", false);
allowTransactionsOnHolidayDefault.put("trapDoor", false);
defaults.add(allowTransactionsOnHolidayDefault);
HashMap<String, Object> allowTransactionsOnNonWorkingDayDefault = new HashMap<>();
allowTransactionsOnNonWorkingDayDefault.put("name", GlobalConfigurationConstants.ALLOW_TRANSACTIONS_ON_NON_WORKING_DAY);
allowTransactionsOnNonWorkingDayDefault.put("value", 0L);
allowTransactionsOnNonWorkingDayDefault.put("enabled", false);
allowTransactionsOnNonWorkingDayDefault.put("trapDoor", false);
defaults.add(allowTransactionsOnNonWorkingDayDefault);
HashMap<String, Object> constraintApproachForDataTablesDefault = new HashMap<>();
constraintApproachForDataTablesDefault.put("name", GlobalConfigurationConstants.CONSTRAINT_APPROACH_FOR_DATATABLES);
constraintApproachForDataTablesDefault.put("value", 0L);
constraintApproachForDataTablesDefault.put("enabled", false);
constraintApproachForDataTablesDefault.put("trapDoor", false);
defaults.add(constraintApproachForDataTablesDefault);
HashMap<String, Object> penaltyWaitPeriodDefault = new HashMap<>();
penaltyWaitPeriodDefault.put("name", GlobalConfigurationConstants.PENALTY_WAIT_PERIOD);
penaltyWaitPeriodDefault.put("value", 2L);
penaltyWaitPeriodDefault.put("enabled", true);
penaltyWaitPeriodDefault.put("trapDoor", false);
defaults.add(penaltyWaitPeriodDefault);
HashMap<String, Object> forcePasswordResetDaysDefault = new HashMap<>();
forcePasswordResetDaysDefault.put("name", GlobalConfigurationConstants.FORCE_PASSWORD_RESET_DAYS);
forcePasswordResetDaysDefault.put("value", 0L);
forcePasswordResetDaysDefault.put("enabled", false);
forcePasswordResetDaysDefault.put("trapDoor", false);
defaults.add(forcePasswordResetDaysDefault);
HashMap<String, Object> graceOnPenaltyPostingDefault = new HashMap<>();
graceOnPenaltyPostingDefault.put("name", GlobalConfigurationConstants.GRACE_ON_PENALTY_POSTING);
graceOnPenaltyPostingDefault.put("value", 0L);
graceOnPenaltyPostingDefault.put("enabled", true);
graceOnPenaltyPostingDefault.put("trapDoor", false);
defaults.add(graceOnPenaltyPostingDefault);
HashMap<String, Object> savingsInterestPostingCurrentPeriodEndDefault = new HashMap<>();
savingsInterestPostingCurrentPeriodEndDefault.put("name", GlobalConfigurationConstants.SAVINGS_INTEREST_POSTING_CURRENT_PERIOD_END);
savingsInterestPostingCurrentPeriodEndDefault.put("value", 0L);
savingsInterestPostingCurrentPeriodEndDefault.put("enabled", false);
savingsInterestPostingCurrentPeriodEndDefault.put("trapDoor", false);
defaults.add(savingsInterestPostingCurrentPeriodEndDefault);
HashMap<String, Object> financialYearBeginningMonthDefault = new HashMap<>();
financialYearBeginningMonthDefault.put("name", GlobalConfigurationConstants.FINANCIAL_YEAR_BEGINNING_MONTH);
financialYearBeginningMonthDefault.put("value", 1L);
financialYearBeginningMonthDefault.put("enabled", true);
financialYearBeginningMonthDefault.put("trapDoor", false);
defaults.add(financialYearBeginningMonthDefault);
HashMap<String, Object> minClientsInGroupDefault = new HashMap<>();
minClientsInGroupDefault.put("name", GlobalConfigurationConstants.MIN_CLIENTS_IN_GROUP);
minClientsInGroupDefault.put("value", 5L);
minClientsInGroupDefault.put("enabled", false);
minClientsInGroupDefault.put("trapDoor", false);
defaults.add(minClientsInGroupDefault);
HashMap<String, Object> maxClientsInGroupDefault = new HashMap<>();
maxClientsInGroupDefault.put("name", GlobalConfigurationConstants.MAX_CLIENTS_IN_GROUP);
maxClientsInGroupDefault.put("value", 5L);
maxClientsInGroupDefault.put("enabled", false);
maxClientsInGroupDefault.put("trapDoor", false);
defaults.add(maxClientsInGroupDefault);
HashMap<String, Object> meetingsMandatoryForJlgLoansDefault = new HashMap<>();
meetingsMandatoryForJlgLoansDefault.put("name", GlobalConfigurationConstants.MEETINGS_MANDATORY_FOR_JLG_LOANS);
meetingsMandatoryForJlgLoansDefault.put("value", 0L);
meetingsMandatoryForJlgLoansDefault.put("enabled", false);
meetingsMandatoryForJlgLoansDefault.put("trapDoor", false);
defaults.add(meetingsMandatoryForJlgLoansDefault);
HashMap<String, Object> officeSpecificProductsEnabledDefault = new HashMap<>();
officeSpecificProductsEnabledDefault.put("name", GlobalConfigurationConstants.OFFICE_SPECIFIC_PRODUCTS_ENABLED);
officeSpecificProductsEnabledDefault.put("value", 0L);
officeSpecificProductsEnabledDefault.put("enabled", false);
officeSpecificProductsEnabledDefault.put("trapDoor", false);
defaults.add(officeSpecificProductsEnabledDefault);
HashMap<String, Object> restrictProductsToUserOfficeDefault = new HashMap<>();
restrictProductsToUserOfficeDefault.put("name", GlobalConfigurationConstants.RESTRICT_PRODUCTS_TO_USER_OFFICE);
restrictProductsToUserOfficeDefault.put("value", 0L);
restrictProductsToUserOfficeDefault.put("enabled", false);
restrictProductsToUserOfficeDefault.put("trapDoor", false);
defaults.add(restrictProductsToUserOfficeDefault);
HashMap<String, Object> officeOpeningBalancesContraAccountDefault = new HashMap<>();
officeOpeningBalancesContraAccountDefault.put("name", GlobalConfigurationConstants.OFFICE_OPENING_BALANCES_CONTRA_ACCOUNT);
officeOpeningBalancesContraAccountDefault.put("value", 0L);
officeOpeningBalancesContraAccountDefault.put("enabled", true);
officeOpeningBalancesContraAccountDefault.put("trapDoor", false);
defaults.add(officeOpeningBalancesContraAccountDefault);
HashMap<String, Object> roundingModeDefault = new HashMap<>();
roundingModeDefault.put("name", GlobalConfigurationConstants.ROUNDING_MODE);
roundingModeDefault.put("value", 6L);
roundingModeDefault.put("enabled", true);
roundingModeDefault.put("trapDoor", true);
defaults.add(roundingModeDefault);
HashMap<String, Object> backDatePenaltiesEnabledDefault = new HashMap<>();
backDatePenaltiesEnabledDefault.put("name", GlobalConfigurationConstants.BACKDATE_PENALTIES_ENABLED);
backDatePenaltiesEnabledDefault.put("value", 0L);
backDatePenaltiesEnabledDefault.put("enabled", true);
backDatePenaltiesEnabledDefault.put("trapDoor", false);
defaults.add(backDatePenaltiesEnabledDefault);
HashMap<String, Object> organisationStartDateDefault = new HashMap<>();
organisationStartDateDefault.put("name", GlobalConfigurationConstants.ORGANISATION_START_DATE);
organisationStartDateDefault.put("value", 0L);
organisationStartDateDefault.put("enabled", false);
organisationStartDateDefault.put("trapDoor", false);
defaults.add(organisationStartDateDefault);
HashMap<String, Object> paymentTypeApplicableForDisbursementChargesDefault = new HashMap<>();
paymentTypeApplicableForDisbursementChargesDefault.put("name",
GlobalConfigurationConstants.PAYMENT_TYPE_APPLICABLE_FOR_DISBURSEMENT_CHARGES);
paymentTypeApplicableForDisbursementChargesDefault.put("value", 0L);
paymentTypeApplicableForDisbursementChargesDefault.put("enabled", false);
paymentTypeApplicableForDisbursementChargesDefault.put("trapDoor", false);
defaults.add(paymentTypeApplicableForDisbursementChargesDefault);
HashMap<String, Object> interestChargedFromDateSameAsDisbursalDateDefault = new HashMap<>();
interestChargedFromDateSameAsDisbursalDateDefault.put("name",
GlobalConfigurationConstants.INTEREST_CHARGED_FROM_DATE_SAME_AS_DISBURSAL_DATE);
interestChargedFromDateSameAsDisbursalDateDefault.put("value", 0L);
interestChargedFromDateSameAsDisbursalDateDefault.put("enabled", false);
interestChargedFromDateSameAsDisbursalDateDefault.put("trapDoor", false);
defaults.add(interestChargedFromDateSameAsDisbursalDateDefault);
HashMap<String, Object> skipRepaymentOnFirstDayOfMonthDefault = new HashMap<>();
skipRepaymentOnFirstDayOfMonthDefault.put("name", GlobalConfigurationConstants.SKIP_REPAYMENT_ON_FIRST_DAY_OF_MONTH);
skipRepaymentOnFirstDayOfMonthDefault.put("value", 14L);
skipRepaymentOnFirstDayOfMonthDefault.put("enabled", false);
skipRepaymentOnFirstDayOfMonthDefault.put("trapDoor", false);
defaults.add(skipRepaymentOnFirstDayOfMonthDefault);
HashMap<String, Object> changeEmiIfRepaymentDateSameAsDisbursementDateDefault = new HashMap<>();
changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("name",
GlobalConfigurationConstants.CHANGE_EMI_IF_REPAYMENT_DATE_SAME_AS_DISBURSEMENT_DATE);
changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("value", 0L);
changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("enabled", true);
changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("trapDoor", false);
defaults.add(changeEmiIfRepaymentDateSameAsDisbursementDateDefault);
HashMap<String, Object> dailyTptLimitDefault = new HashMap<>();
dailyTptLimitDefault.put("name", GlobalConfigurationConstants.DAILY_TPT_LIMIT);
dailyTptLimitDefault.put("value", 0L);
dailyTptLimitDefault.put("enabled", false);
dailyTptLimitDefault.put("trapDoor", false);
defaults.add(dailyTptLimitDefault);
HashMap<String, Object> enableAddressDefault = new HashMap<>();
enableAddressDefault.put("name", GlobalConfigurationConstants.ENABLE_ADDRESS);
enableAddressDefault.put("value", 0L);
enableAddressDefault.put("enabled", false);
enableAddressDefault.put("trapDoor", false);
defaults.add(enableAddressDefault);
HashMap<String, Object> enableSubRatesDefault = new HashMap<>();
enableSubRatesDefault.put("name", GlobalConfigurationConstants.SUB_RATES);
enableSubRatesDefault.put("value", 0L);
enableSubRatesDefault.put("enabled", false);
enableSubRatesDefault.put("trapDoor", false);
defaults.add(enableSubRatesDefault);
HashMap<String, Object> isFirstPaydayAllowedOnHoliday = new HashMap<>();
isFirstPaydayAllowedOnHoliday.put("name", GlobalConfigurationConstants.LOAN_RESCHEDULE_IS_FIRST_PAYDAY_ALLOWED_ON_HOLIDAY);
isFirstPaydayAllowedOnHoliday.put("value", 0L);
isFirstPaydayAllowedOnHoliday.put("enabled", false);
isFirstPaydayAllowedOnHoliday.put("trapDoor", false);
defaults.add(isFirstPaydayAllowedOnHoliday);
HashMap<String, Object> isAccountMappedForPayment = new HashMap<>();
isAccountMappedForPayment.put("name", GlobalConfigurationConstants.ACCOUNT_MAPPING_FOR_PAYMENT_TYPE);
isAccountMappedForPayment.put("value", 0L);
isAccountMappedForPayment.put("enabled", true);
isAccountMappedForPayment.put("trapDoor", false);
isAccountMappedForPayment.put("string_value", "Asset");
defaults.add(isAccountMappedForPayment);
HashMap<String, Object> isAccountMappedForCharge = new HashMap<>();
isAccountMappedForCharge.put("name", GlobalConfigurationConstants.ACCOUNT_MAPPING_FOR_CHARGE);
isAccountMappedForCharge.put("value", 0L);
isAccountMappedForCharge.put("enabled", true);
isAccountMappedForCharge.put("trapDoor", false);
isAccountMappedForCharge.put("string_value", "Income");
defaults.add(isAccountMappedForCharge);
HashMap<String, Object> isNextDayFixedDepositInterestTransferEnabledForPeriodEnd = new HashMap<>();
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("name",
GlobalConfigurationConstants.FIXED_DEPOSIT_TRANSFER_INTEREST_NEXT_DAY_FOR_PERIOD_END_POSTING);
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("value", 0L);
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("enabled", false);
isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("trapDoor", false);
defaults.add(isNextDayFixedDepositInterestTransferEnabledForPeriodEnd);
HashMap<String, Object> isAllowedBackDatedTransactionsBeforeInterestPostingDate = new HashMap<>();
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("name",
GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING);
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("value", 0L);
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("enabled", true);
isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("trapDoor", false);
defaults.add(isAllowedBackDatedTransactionsBeforeInterestPostingDate);
HashMap<String, Object> isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays = new HashMap<>();
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("name",
GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING_DATE_FOR_DAYS);
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("value", 0L);
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("enabled", false);
isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("trapDoor", false);
defaults.add(isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays);
HashMap<String, Object> isClientAccountNumberLengthModify = new HashMap<>();
isClientAccountNumberLengthModify.put("name", GlobalConfigurationConstants.CUSTOM_ACCOUNT_NUMBER_LENGTH);
isClientAccountNumberLengthModify.put("value", 0L);
isClientAccountNumberLengthModify.put("enabled", false);
isClientAccountNumberLengthModify.put("trapDoor", false);
defaults.add(isClientAccountNumberLengthModify);
HashMap<String, Object> isAccountNumberRandomGenerated = new HashMap<>();
isAccountNumberRandomGenerated.put("name", GlobalConfigurationConstants.RANDOM_ACCOUNT_NUMBER);
isAccountNumberRandomGenerated.put("value", 0L);
isAccountNumberRandomGenerated.put("enabled", false);
isAccountNumberRandomGenerated.put("trapDoor", false);
defaults.add(isAccountNumberRandomGenerated);
HashMap<String, Object> isInterestAppropriationEnabled = new HashMap<>();
isInterestAppropriationEnabled.put("name", GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI);
isInterestAppropriationEnabled.put("value", 0L);
isInterestAppropriationEnabled.put("enabled", false);
isInterestAppropriationEnabled.put("trapDoor", false);
defaults.add(isInterestAppropriationEnabled);
HashMap<String, Object> isPrincipalCompoundingDisabled = new HashMap<>();
isPrincipalCompoundingDisabled.put("name", GlobalConfigurationConstants.IS_PRINCIPAL_COMPOUNDING_DISABLED_FOR_OVERDUE_LOANS);
isPrincipalCompoundingDisabled.put("value", 0L);
isPrincipalCompoundingDisabled.put("enabled", false);
isPrincipalCompoundingDisabled.put("trapDoor", false);
defaults.add(isPrincipalCompoundingDisabled);
HashMap<String, Object> isBusinessDateEnabled = new HashMap<>();
isBusinessDateEnabled.put("name", GlobalConfigurationConstants.ENABLE_BUSINESS_DATE);
isBusinessDateEnabled.put("value", 0L);
isBusinessDateEnabled.put("enabled", false);
isBusinessDateEnabled.put("trapDoor", false);
defaults.add(isBusinessDateEnabled);
HashMap<String, Object> isAutomaticCOBDateAdjustmentEnabled = new HashMap<>();
isAutomaticCOBDateAdjustmentEnabled.put("name", GlobalConfigurationConstants.ENABLE_AUTOMATIC_COB_DATE_ADJUSTMENT);
isAutomaticCOBDateAdjustmentEnabled.put("value", 0L);
isAutomaticCOBDateAdjustmentEnabled.put("enabled", true);
isAutomaticCOBDateAdjustmentEnabled.put("trapDoor", false);
defaults.add(isAutomaticCOBDateAdjustmentEnabled);
HashMap<String, Object> isReversalTransactionAllowed = new HashMap<>();
isReversalTransactionAllowed.put("name", GlobalConfigurationConstants.ENABLE_POST_REVERSAL_TXNS_FOR_REVERSE_TRANSACTIONS);
isReversalTransactionAllowed.put("value", 0L);
isReversalTransactionAllowed.put("enabled", false);
isReversalTransactionAllowed.put("trapDoor", false);
defaults.add(isReversalTransactionAllowed);
HashMap<String, Object> purgeExternalEventsOlderThanDaysDefault = new HashMap<>();
purgeExternalEventsOlderThanDaysDefault.put("name", GlobalConfigurationConstants.PURGE_EXTERNAL_EVENTS_OLDER_THAN_DAYS);
purgeExternalEventsOlderThanDaysDefault.put("value", 30L);
purgeExternalEventsOlderThanDaysDefault.put("enabled", false);
purgeExternalEventsOlderThanDaysDefault.put("trapDoor", false);
defaults.add(purgeExternalEventsOlderThanDaysDefault);
HashMap<String, Object> loanRepaymentDueDaysDefault = new HashMap<>();
loanRepaymentDueDaysDefault.put("name", GlobalConfigurationConstants.DAYS_BEFORE_REPAYMENT_IS_DUE);
loanRepaymentDueDaysDefault.put("value", 1L);
loanRepaymentDueDaysDefault.put("enabled", false);
loanRepaymentDueDaysDefault.put("trapDoor", false);
defaults.add(loanRepaymentDueDaysDefault);
HashMap<String, Object> loanRepaymentOverdueDaysDefault = new HashMap<>();
loanRepaymentOverdueDaysDefault.put("name", GlobalConfigurationConstants.DAYS_AFTER_REPAYMENT_IS_OVERDUE);
loanRepaymentOverdueDaysDefault.put("value", 1L);
loanRepaymentOverdueDaysDefault.put("enabled", false);
loanRepaymentOverdueDaysDefault.put("trapDoor", false);
defaults.add(loanRepaymentOverdueDaysDefault);
HashMap<String, Object> isAutomaticExternalIdGenerationEnabled = new HashMap<>();
isAutomaticExternalIdGenerationEnabled.put("name", GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID);
isAutomaticExternalIdGenerationEnabled.put("value", 0L);
isAutomaticExternalIdGenerationEnabled.put("enabled", false);
isAutomaticExternalIdGenerationEnabled.put("trapDoor", false);
defaults.add(isAutomaticExternalIdGenerationEnabled);
HashMap<String, Object> purgeProcessCommandDaysDefault = new HashMap<>();
purgeProcessCommandDaysDefault.put("name", GlobalConfigurationConstants.PURGE_PROCESSED_COMMANDS_OLDER_THAN_DAYS);
purgeProcessCommandDaysDefault.put("value", 30L);
purgeProcessCommandDaysDefault.put("enabled", false);
purgeProcessCommandDaysDefault.put("trapDoor", false);
defaults.add(purgeProcessCommandDaysDefault);
HashMap<String, Object> isCOBBulkEventEnabled = new HashMap<>();
isCOBBulkEventEnabled.put("name", GlobalConfigurationConstants.ENABLE_COB_BULK_EVENT);
isCOBBulkEventEnabled.put("value", 0L);
isCOBBulkEventEnabled.put("enabled", false);
isCOBBulkEventEnabled.put("trapDoor", false);
defaults.add(isCOBBulkEventEnabled);
HashMap<String, Object> externalEventBatchSize = new HashMap<>();
externalEventBatchSize.put("name", GlobalConfigurationConstants.EXTERNAL_EVENT_BATCH_SIZE);
externalEventBatchSize.put("value", 1000L);
externalEventBatchSize.put("enabled", false);
externalEventBatchSize.put("trapDoor", false);
defaults.add(externalEventBatchSize);
HashMap<String, Object> reportExportS3FolderName = new HashMap<>();
reportExportS3FolderName.put("name", GlobalConfigurationConstants.REPORT_EXPORT_S3_FOLDER_NAME);
reportExportS3FolderName.put("value", 0L);
reportExportS3FolderName.put("enabled", true);
reportExportS3FolderName.put("trapDoor", false);
defaults.add(reportExportS3FolderName);
HashMap<String, Object> loanArrearsDelinquencyDisplayData = new HashMap<>();
loanArrearsDelinquencyDisplayData.put("name", GlobalConfigurationConstants.LOAN_ARREARS_DELINQUENCY_DISPLAY_DATA);
loanArrearsDelinquencyDisplayData.put("value", 0L);
loanArrearsDelinquencyDisplayData.put("enabled", true);
loanArrearsDelinquencyDisplayData.put("trapDoor", false);
defaults.add(loanArrearsDelinquencyDisplayData);
HashMap<String, Object> accrualForChargeDate = new HashMap<>();
accrualForChargeDate.put("name", GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE);
accrualForChargeDate.put("value", 0L);
accrualForChargeDate.put("enabled", true);
accrualForChargeDate.put("trapDoor", false);
accrualForChargeDate.put("string_value", "due-date");
defaults.add(accrualForChargeDate);
HashMap<String, Object> assetExternalizationOfNonActiveLoans = new HashMap<>();
assetExternalizationOfNonActiveLoans.put("name", GlobalConfigurationConstants.ASSET_EXTERNALIZATION_OF_NON_ACTIVE_LOANS);
assetExternalizationOfNonActiveLoans.put("value", 0L);
assetExternalizationOfNonActiveLoans.put("enabled", true);
assetExternalizationOfNonActiveLoans.put("trapDoor", false);
defaults.add(assetExternalizationOfNonActiveLoans);
HashMap<String, Object> enableSameMakerChecker = new HashMap<>();
enableSameMakerChecker.put("name", GlobalConfigurationConstants.ENABLE_SAME_MAKER_CHECKER);
enableSameMakerChecker.put("value", 0L);
enableSameMakerChecker.put("enabled", false);
enableSameMakerChecker.put("trapDoor", false);
defaults.add(enableSameMakerChecker);
HashMap<String, Object> nextPaymentDateConfigForLoan = new HashMap<>();
nextPaymentDateConfigForLoan.put("name", GlobalConfigurationConstants.NEXT_PAYMENT_DUE_DATE);
nextPaymentDateConfigForLoan.put("value", 0L);
nextPaymentDateConfigForLoan.put("enabled", true);
nextPaymentDateConfigForLoan.put("trapDoor", false);
nextPaymentDateConfigForLoan.put("string_value", "earliest-unpaid-date");
defaults.add(nextPaymentDateConfigForLoan);
HashMap<String, Object> enablePaymentHubIntegrationConfig = new HashMap<>();
enablePaymentHubIntegrationConfig.put("name", GlobalConfigurationConstants.ENABLE_PAYMENT_HUB_INTEGRATION);
enablePaymentHubIntegrationConfig.put("value", 0L);
enablePaymentHubIntegrationConfig.put("enabled", false);
enablePaymentHubIntegrationConfig.put("trapDoor", false);
enablePaymentHubIntegrationConfig.put("string_value", "enable payment hub integration");
defaults.add(enablePaymentHubIntegrationConfig);
HashMap<String, Object> enableImmediateChargeAccrualPostMaturity = new HashMap<>();
enableImmediateChargeAccrualPostMaturity.put("name", GlobalConfigurationConstants.ENABLE_IMMEDIATE_CHARGE_ACCRUAL_POST_MATURITY);
enableImmediateChargeAccrualPostMaturity.put("value", 0L);
enableImmediateChargeAccrualPostMaturity.put("enabled", false);
enableImmediateChargeAccrualPostMaturity.put("trapDoor", false);
defaults.add(enableImmediateChargeAccrualPostMaturity);
HashMap<String, Object> assetOwnerTransferInterestOutstandingStrategy = new HashMap<>();
assetOwnerTransferInterestOutstandingStrategy.put("name",
GlobalConfigurationConstants.ASSET_OWNER_TRANSFER_OUTSTANDING_INTEREST_CALCULATION_STRATEGY);
assetOwnerTransferInterestOutstandingStrategy.put("value", 0L);
assetOwnerTransferInterestOutstandingStrategy.put("enabled", true);
assetOwnerTransferInterestOutstandingStrategy.put("trapDoor", false);
assetOwnerTransferInterestOutstandingStrategy.put("string_value", "TOTAL_OUTSTANDING_INTEREST");
defaults.add(assetOwnerTransferInterestOutstandingStrategy);
HashMap<String, Object> allowedLoanStatusesForExternalAssetTransfer = new HashMap<>();
allowedLoanStatusesForExternalAssetTransfer.put("name",
GlobalConfigurationConstants.ALLOWED_LOAN_STATUSES_FOR_EXTERNAL_ASSET_TRANSFER);
allowedLoanStatusesForExternalAssetTransfer.put("value", 0L);
allowedLoanStatusesForExternalAssetTransfer.put("enabled", true);
allowedLoanStatusesForExternalAssetTransfer.put("trapDoor", false);
allowedLoanStatusesForExternalAssetTransfer.put("string_value", "ACTIVE,TRANSFER_IN_PROGRESS,TRANSFER_ON_HOLD");
defaults.add(allowedLoanStatusesForExternalAssetTransfer);
HashMap<String, Object> allowedLoanStatusesForDelayedSettlementExternalAssetTransfer = new HashMap<>();
allowedLoanStatusesForDelayedSettlementExternalAssetTransfer.put("name",
GlobalConfigurationConstants.ALLOWED_LOAN_STATUSES_OF_DELAYED_SETTLEMENT_FOR_EXTERNAL_ASSET_TRANSFER);
allowedLoanStatusesForDelayedSettlementExternalAssetTransfer.put("value", 0L);
allowedLoanStatusesForDelayedSettlementExternalAssetTransfer.put("enabled", true);
allowedLoanStatusesForDelayedSettlementExternalAssetTransfer.put("trapDoor", false);
allowedLoanStatusesForDelayedSettlementExternalAssetTransfer.put("string_value",
"ACTIVE,TRANSFER_IN_PROGRESS,TRANSFER_ON_HOLD,OVERPAID,CLOSED_OBLIGATIONS_MET");
defaults.add(allowedLoanStatusesForDelayedSettlementExternalAssetTransfer);
return defaults;
}
public PutGlobalConfigurationsResponse updateGlobalConfiguration(final String configName, PutGlobalConfigurationsRequest request) {
log.info("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------");
return Calls.ok(FineractClientHelper.getFineractClient().globalConfigurations.updateConfigurationByName(configName, request));
}
public void updateGlobalConfigurationInternal(final String configName, final Long value) {
log.info("---------------------------UPDATE VALUE FOR GLOBAL CONFIG (internal) ---------------------------------------");
Calls.ok(FineractClientHelper.getFineractClient().legacy.updateGlobalConfiguration(configName, value));
}
public void manageConfigurations(final String configurationName, final boolean enabled) {
GlobalConfigurationPropertyData configuration = getGlobalConfigurationByName(configurationName);
assertNotNull(configuration);
updateGlobalConfiguration(configurationName, new PutGlobalConfigurationsRequest().enabled(enabled));
GlobalConfigurationPropertyData updatedConfiguration = getGlobalConfigurationByName(configurationName);
assertEquals(updatedConfiguration.getEnabled(), enabled);
}
}
|
googleapis/google-cloud-java | 36,308 | java-appengine-admin/proto-google-cloud-appengine-admin-v1/src/main/java/com/google/appengine/v1/ListIngressRulesResponse.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/appengine/v1/appengine.proto
// Protobuf Java Version: 3.25.8
package com.google.appengine.v1;
/**
*
*
* <pre>
* Response message for `Firewall.ListIngressRules`.
* </pre>
*
* Protobuf type {@code google.appengine.v1.ListIngressRulesResponse}
*/
public final class ListIngressRulesResponse extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.appengine.v1.ListIngressRulesResponse)
ListIngressRulesResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use ListIngressRulesResponse.newBuilder() to construct.
private ListIngressRulesResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ListIngressRulesResponse() {
ingressRules_ = java.util.Collections.emptyList();
nextPageToken_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ListIngressRulesResponse();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.appengine.v1.AppengineProto
.internal_static_google_appengine_v1_ListIngressRulesResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.appengine.v1.AppengineProto
.internal_static_google_appengine_v1_ListIngressRulesResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.appengine.v1.ListIngressRulesResponse.class,
com.google.appengine.v1.ListIngressRulesResponse.Builder.class);
}
public static final int INGRESS_RULES_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private java.util.List<com.google.appengine.v1.firewall.FirewallRule> ingressRules_;
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
@java.lang.Override
public java.util.List<com.google.appengine.v1.firewall.FirewallRule> getIngressRulesList() {
return ingressRules_;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
@java.lang.Override
public java.util.List<? extends com.google.appengine.v1.firewall.FirewallRuleOrBuilder>
getIngressRulesOrBuilderList() {
return ingressRules_;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
@java.lang.Override
public int getIngressRulesCount() {
return ingressRules_.size();
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
@java.lang.Override
public com.google.appengine.v1.firewall.FirewallRule getIngressRules(int index) {
return ingressRules_.get(index);
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
@java.lang.Override
public com.google.appengine.v1.firewall.FirewallRuleOrBuilder getIngressRulesOrBuilder(
int index) {
return ingressRules_.get(index);
}
public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Continuation token for fetching the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
@java.lang.Override
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
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();
nextPageToken_ = s;
return s;
}
}
/**
*
*
* <pre>
* Continuation token for fetching the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 {
for (int i = 0; i < ingressRules_.size(); i++) {
output.writeMessage(1, ingressRules_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
for (int i = 0; i < ingressRules_.size(); i++) {
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, ingressRules_.get(i));
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_);
}
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.appengine.v1.ListIngressRulesResponse)) {
return super.equals(obj);
}
com.google.appengine.v1.ListIngressRulesResponse other =
(com.google.appengine.v1.ListIngressRulesResponse) obj;
if (!getIngressRulesList().equals(other.getIngressRulesList())) return false;
if (!getNextPageToken().equals(other.getNextPageToken())) 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 (getIngressRulesCount() > 0) {
hash = (37 * hash) + INGRESS_RULES_FIELD_NUMBER;
hash = (53 * hash) + getIngressRulesList().hashCode();
}
hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getNextPageToken().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.appengine.v1.ListIngressRulesResponse parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.appengine.v1.ListIngressRulesResponse parseFrom(
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.appengine.v1.ListIngressRulesResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.appengine.v1.ListIngressRulesResponse 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.appengine.v1.ListIngressRulesResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.appengine.v1.ListIngressRulesResponse parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.appengine.v1.ListIngressRulesResponse parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.appengine.v1.ListIngressRulesResponse 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.appengine.v1.ListIngressRulesResponse parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.appengine.v1.ListIngressRulesResponse 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.appengine.v1.ListIngressRulesResponse parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.appengine.v1.ListIngressRulesResponse 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.appengine.v1.ListIngressRulesResponse 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;
}
/**
*
*
* <pre>
* Response message for `Firewall.ListIngressRules`.
* </pre>
*
* Protobuf type {@code google.appengine.v1.ListIngressRulesResponse}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.appengine.v1.ListIngressRulesResponse)
com.google.appengine.v1.ListIngressRulesResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.appengine.v1.AppengineProto
.internal_static_google_appengine_v1_ListIngressRulesResponse_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.appengine.v1.AppengineProto
.internal_static_google_appengine_v1_ListIngressRulesResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.appengine.v1.ListIngressRulesResponse.class,
com.google.appengine.v1.ListIngressRulesResponse.Builder.class);
}
// Construct using com.google.appengine.v1.ListIngressRulesResponse.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
if (ingressRulesBuilder_ == null) {
ingressRules_ = java.util.Collections.emptyList();
} else {
ingressRules_ = null;
ingressRulesBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000001);
nextPageToken_ = "";
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.appengine.v1.AppengineProto
.internal_static_google_appengine_v1_ListIngressRulesResponse_descriptor;
}
@java.lang.Override
public com.google.appengine.v1.ListIngressRulesResponse getDefaultInstanceForType() {
return com.google.appengine.v1.ListIngressRulesResponse.getDefaultInstance();
}
@java.lang.Override
public com.google.appengine.v1.ListIngressRulesResponse build() {
com.google.appengine.v1.ListIngressRulesResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.appengine.v1.ListIngressRulesResponse buildPartial() {
com.google.appengine.v1.ListIngressRulesResponse result =
new com.google.appengine.v1.ListIngressRulesResponse(this);
buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartialRepeatedFields(
com.google.appengine.v1.ListIngressRulesResponse result) {
if (ingressRulesBuilder_ == null) {
if (((bitField0_ & 0x00000001) != 0)) {
ingressRules_ = java.util.Collections.unmodifiableList(ingressRules_);
bitField0_ = (bitField0_ & ~0x00000001);
}
result.ingressRules_ = ingressRules_;
} else {
result.ingressRules_ = ingressRulesBuilder_.build();
}
}
private void buildPartial0(com.google.appengine.v1.ListIngressRulesResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000002) != 0)) {
result.nextPageToken_ = nextPageToken_;
}
}
@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.appengine.v1.ListIngressRulesResponse) {
return mergeFrom((com.google.appengine.v1.ListIngressRulesResponse) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.appengine.v1.ListIngressRulesResponse other) {
if (other == com.google.appengine.v1.ListIngressRulesResponse.getDefaultInstance())
return this;
if (ingressRulesBuilder_ == null) {
if (!other.ingressRules_.isEmpty()) {
if (ingressRules_.isEmpty()) {
ingressRules_ = other.ingressRules_;
bitField0_ = (bitField0_ & ~0x00000001);
} else {
ensureIngressRulesIsMutable();
ingressRules_.addAll(other.ingressRules_);
}
onChanged();
}
} else {
if (!other.ingressRules_.isEmpty()) {
if (ingressRulesBuilder_.isEmpty()) {
ingressRulesBuilder_.dispose();
ingressRulesBuilder_ = null;
ingressRules_ = other.ingressRules_;
bitField0_ = (bitField0_ & ~0x00000001);
ingressRulesBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
? getIngressRulesFieldBuilder()
: null;
} else {
ingressRulesBuilder_.addAllMessages(other.ingressRules_);
}
}
}
if (!other.getNextPageToken().isEmpty()) {
nextPageToken_ = other.nextPageToken_;
bitField0_ |= 0x00000002;
onChanged();
}
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 10:
{
com.google.appengine.v1.firewall.FirewallRule m =
input.readMessage(
com.google.appengine.v1.firewall.FirewallRule.parser(), extensionRegistry);
if (ingressRulesBuilder_ == null) {
ensureIngressRulesIsMutable();
ingressRules_.add(m);
} else {
ingressRulesBuilder_.addMessage(m);
}
break;
} // case 10
case 18:
{
nextPageToken_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
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.appengine.v1.firewall.FirewallRule> ingressRules_ =
java.util.Collections.emptyList();
private void ensureIngressRulesIsMutable() {
if (!((bitField0_ & 0x00000001) != 0)) {
ingressRules_ =
new java.util.ArrayList<com.google.appengine.v1.firewall.FirewallRule>(ingressRules_);
bitField0_ |= 0x00000001;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.appengine.v1.firewall.FirewallRule,
com.google.appengine.v1.firewall.FirewallRule.Builder,
com.google.appengine.v1.firewall.FirewallRuleOrBuilder>
ingressRulesBuilder_;
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public java.util.List<com.google.appengine.v1.firewall.FirewallRule> getIngressRulesList() {
if (ingressRulesBuilder_ == null) {
return java.util.Collections.unmodifiableList(ingressRules_);
} else {
return ingressRulesBuilder_.getMessageList();
}
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public int getIngressRulesCount() {
if (ingressRulesBuilder_ == null) {
return ingressRules_.size();
} else {
return ingressRulesBuilder_.getCount();
}
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public com.google.appengine.v1.firewall.FirewallRule getIngressRules(int index) {
if (ingressRulesBuilder_ == null) {
return ingressRules_.get(index);
} else {
return ingressRulesBuilder_.getMessage(index);
}
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder setIngressRules(int index, com.google.appengine.v1.firewall.FirewallRule value) {
if (ingressRulesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureIngressRulesIsMutable();
ingressRules_.set(index, value);
onChanged();
} else {
ingressRulesBuilder_.setMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder setIngressRules(
int index, com.google.appengine.v1.firewall.FirewallRule.Builder builderForValue) {
if (ingressRulesBuilder_ == null) {
ensureIngressRulesIsMutable();
ingressRules_.set(index, builderForValue.build());
onChanged();
} else {
ingressRulesBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder addIngressRules(com.google.appengine.v1.firewall.FirewallRule value) {
if (ingressRulesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureIngressRulesIsMutable();
ingressRules_.add(value);
onChanged();
} else {
ingressRulesBuilder_.addMessage(value);
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder addIngressRules(int index, com.google.appengine.v1.firewall.FirewallRule value) {
if (ingressRulesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureIngressRulesIsMutable();
ingressRules_.add(index, value);
onChanged();
} else {
ingressRulesBuilder_.addMessage(index, value);
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder addIngressRules(
com.google.appengine.v1.firewall.FirewallRule.Builder builderForValue) {
if (ingressRulesBuilder_ == null) {
ensureIngressRulesIsMutable();
ingressRules_.add(builderForValue.build());
onChanged();
} else {
ingressRulesBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder addIngressRules(
int index, com.google.appengine.v1.firewall.FirewallRule.Builder builderForValue) {
if (ingressRulesBuilder_ == null) {
ensureIngressRulesIsMutable();
ingressRules_.add(index, builderForValue.build());
onChanged();
} else {
ingressRulesBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder addAllIngressRules(
java.lang.Iterable<? extends com.google.appengine.v1.firewall.FirewallRule> values) {
if (ingressRulesBuilder_ == null) {
ensureIngressRulesIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(values, ingressRules_);
onChanged();
} else {
ingressRulesBuilder_.addAllMessages(values);
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder clearIngressRules() {
if (ingressRulesBuilder_ == null) {
ingressRules_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
} else {
ingressRulesBuilder_.clear();
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public Builder removeIngressRules(int index) {
if (ingressRulesBuilder_ == null) {
ensureIngressRulesIsMutable();
ingressRules_.remove(index);
onChanged();
} else {
ingressRulesBuilder_.remove(index);
}
return this;
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public com.google.appengine.v1.firewall.FirewallRule.Builder getIngressRulesBuilder(int index) {
return getIngressRulesFieldBuilder().getBuilder(index);
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public com.google.appengine.v1.firewall.FirewallRuleOrBuilder getIngressRulesOrBuilder(
int index) {
if (ingressRulesBuilder_ == null) {
return ingressRules_.get(index);
} else {
return ingressRulesBuilder_.getMessageOrBuilder(index);
}
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public java.util.List<? extends com.google.appengine.v1.firewall.FirewallRuleOrBuilder>
getIngressRulesOrBuilderList() {
if (ingressRulesBuilder_ != null) {
return ingressRulesBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(ingressRules_);
}
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public com.google.appengine.v1.firewall.FirewallRule.Builder addIngressRulesBuilder() {
return getIngressRulesFieldBuilder()
.addBuilder(com.google.appengine.v1.firewall.FirewallRule.getDefaultInstance());
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public com.google.appengine.v1.firewall.FirewallRule.Builder addIngressRulesBuilder(int index) {
return getIngressRulesFieldBuilder()
.addBuilder(index, com.google.appengine.v1.firewall.FirewallRule.getDefaultInstance());
}
/**
*
*
* <pre>
* The ingress FirewallRules for this application.
* </pre>
*
* <code>repeated .google.appengine.v1.FirewallRule ingress_rules = 1;</code>
*/
public java.util.List<com.google.appengine.v1.firewall.FirewallRule.Builder>
getIngressRulesBuilderList() {
return getIngressRulesFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.google.appengine.v1.firewall.FirewallRule,
com.google.appengine.v1.firewall.FirewallRule.Builder,
com.google.appengine.v1.firewall.FirewallRuleOrBuilder>
getIngressRulesFieldBuilder() {
if (ingressRulesBuilder_ == null) {
ingressRulesBuilder_ =
new com.google.protobuf.RepeatedFieldBuilderV3<
com.google.appengine.v1.firewall.FirewallRule,
com.google.appengine.v1.firewall.FirewallRule.Builder,
com.google.appengine.v1.firewall.FirewallRuleOrBuilder>(
ingressRules_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
ingressRules_ = null;
}
return ingressRulesBuilder_;
}
private java.lang.Object nextPageToken_ = "";
/**
*
*
* <pre>
* Continuation token for fetching the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The nextPageToken.
*/
public java.lang.String getNextPageToken() {
java.lang.Object ref = nextPageToken_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
nextPageToken_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Continuation token for fetching the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return The bytes for nextPageToken.
*/
public com.google.protobuf.ByteString getNextPageTokenBytes() {
java.lang.Object ref = nextPageToken_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
nextPageToken_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Continuation token for fetching the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageToken(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Continuation token for fetching the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @return This builder for chaining.
*/
public Builder clearNextPageToken() {
nextPageToken_ = getDefaultInstance().getNextPageToken();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Continuation token for fetching the next page of results.
* </pre>
*
* <code>string next_page_token = 2;</code>
*
* @param value The bytes for nextPageToken to set.
* @return This builder for chaining.
*/
public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
nextPageToken_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.appengine.v1.ListIngressRulesResponse)
}
// @@protoc_insertion_point(class_scope:google.appengine.v1.ListIngressRulesResponse)
private static final com.google.appengine.v1.ListIngressRulesResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.appengine.v1.ListIngressRulesResponse();
}
public static com.google.appengine.v1.ListIngressRulesResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ListIngressRulesResponse> PARSER =
new com.google.protobuf.AbstractParser<ListIngressRulesResponse>() {
@java.lang.Override
public ListIngressRulesResponse 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<ListIngressRulesResponse> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ListIngressRulesResponse> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.appengine.v1.ListIngressRulesResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-cloud-java | 36,312 | java-compute/proto-google-cloud-compute-v1/src/main/java/com/google/cloud/compute/v1/ManagedInstanceInstanceHealth.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/compute/v1/compute.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.compute.v1;
/**
*
*
* <pre>
* </pre>
*
* Protobuf type {@code google.cloud.compute.v1.ManagedInstanceInstanceHealth}
*/
public final class ManagedInstanceInstanceHealth extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.compute.v1.ManagedInstanceInstanceHealth)
ManagedInstanceInstanceHealthOrBuilder {
private static final long serialVersionUID = 0L;
// Use ManagedInstanceInstanceHealth.newBuilder() to construct.
private ManagedInstanceInstanceHealth(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ManagedInstanceInstanceHealth() {
detailedHealthState_ = "";
healthCheck_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new ManagedInstanceInstanceHealth();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_ManagedInstanceInstanceHealth_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_ManagedInstanceInstanceHealth_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.class,
com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.Builder.class);
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* </pre>
*
* Protobuf enum {@code google.cloud.compute.v1.ManagedInstanceInstanceHealth.DetailedHealthState}
*/
public enum DetailedHealthState implements com.google.protobuf.ProtocolMessageEnum {
/**
*
*
* <pre>
* A value indicating that the enum field is not set.
* </pre>
*
* <code>UNDEFINED_DETAILED_HEALTH_STATE = 0;</code>
*/
UNDEFINED_DETAILED_HEALTH_STATE(0),
/**
*
*
* <pre>
* The instance is being drained. The existing connections to the instance have time to complete, but the new ones are being refused.
* </pre>
*
* <code>DRAINING = 480455402;</code>
*/
DRAINING(480455402),
/**
*
*
* <pre>
* The instance is reachable i.e. a connection to the application health checking endpoint can be established, and conforms to the requirements defined by the health check.
* </pre>
*
* <code>HEALTHY = 439801213;</code>
*/
HEALTHY(439801213),
/**
*
*
* <pre>
* The instance is unreachable i.e. a connection to the application health checking endpoint cannot be established, or the server does not respond within the specified timeout.
* </pre>
*
* <code>TIMEOUT = 477813057;</code>
*/
TIMEOUT(477813057),
/**
*
*
* <pre>
* The instance is reachable, but does not conform to the requirements defined by the health check.
* </pre>
*
* <code>UNHEALTHY = 462118084;</code>
*/
UNHEALTHY(462118084),
/**
*
*
* <pre>
* The health checking system is aware of the instance but its health is not known at the moment.
* </pre>
*
* <code>UNKNOWN = 433141802;</code>
*/
UNKNOWN(433141802),
UNRECOGNIZED(-1),
;
/**
*
*
* <pre>
* A value indicating that the enum field is not set.
* </pre>
*
* <code>UNDEFINED_DETAILED_HEALTH_STATE = 0;</code>
*/
public static final int UNDEFINED_DETAILED_HEALTH_STATE_VALUE = 0;
/**
*
*
* <pre>
* The instance is being drained. The existing connections to the instance have time to complete, but the new ones are being refused.
* </pre>
*
* <code>DRAINING = 480455402;</code>
*/
public static final int DRAINING_VALUE = 480455402;
/**
*
*
* <pre>
* The instance is reachable i.e. a connection to the application health checking endpoint can be established, and conforms to the requirements defined by the health check.
* </pre>
*
* <code>HEALTHY = 439801213;</code>
*/
public static final int HEALTHY_VALUE = 439801213;
/**
*
*
* <pre>
* The instance is unreachable i.e. a connection to the application health checking endpoint cannot be established, or the server does not respond within the specified timeout.
* </pre>
*
* <code>TIMEOUT = 477813057;</code>
*/
public static final int TIMEOUT_VALUE = 477813057;
/**
*
*
* <pre>
* The instance is reachable, but does not conform to the requirements defined by the health check.
* </pre>
*
* <code>UNHEALTHY = 462118084;</code>
*/
public static final int UNHEALTHY_VALUE = 462118084;
/**
*
*
* <pre>
* The health checking system is aware of the instance but its health is not known at the moment.
* </pre>
*
* <code>UNKNOWN = 433141802;</code>
*/
public static final int UNKNOWN_VALUE = 433141802;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static DetailedHealthState valueOf(int value) {
return forNumber(value);
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
*/
public static DetailedHealthState forNumber(int value) {
switch (value) {
case 0:
return UNDEFINED_DETAILED_HEALTH_STATE;
case 480455402:
return DRAINING;
case 439801213:
return HEALTHY;
case 477813057:
return TIMEOUT;
case 462118084:
return UNHEALTHY;
case 433141802:
return UNKNOWN;
default:
return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<DetailedHealthState>
internalGetValueMap() {
return internalValueMap;
}
private static final com.google.protobuf.Internal.EnumLiteMap<DetailedHealthState>
internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<DetailedHealthState>() {
public DetailedHealthState findValueByNumber(int number) {
return DetailedHealthState.forNumber(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalStateException(
"Can't get the descriptor of an unrecognized enum value.");
}
return getDescriptor().getValues().get(ordinal());
}
public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
return com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.getDescriptor()
.getEnumTypes()
.get(0);
}
private static final DetailedHealthState[] VALUES = values();
public static DetailedHealthState valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
}
if (desc.getIndex() == -1) {
return UNRECOGNIZED;
}
return VALUES[desc.getIndex()];
}
private final int value;
private DetailedHealthState(int value) {
this.value = value;
}
// @@protoc_insertion_point(enum_scope:google.cloud.compute.v1.ManagedInstanceInstanceHealth.DetailedHealthState)
}
private int bitField0_;
public static final int DETAILED_HEALTH_STATE_FIELD_NUMBER = 510470173;
@SuppressWarnings("serial")
private volatile java.lang.Object detailedHealthState_ = "";
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @return Whether the detailedHealthState field is set.
*/
@java.lang.Override
public boolean hasDetailedHealthState() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @return The detailedHealthState.
*/
@java.lang.Override
public java.lang.String getDetailedHealthState() {
java.lang.Object ref = detailedHealthState_;
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();
detailedHealthState_ = s;
return s;
}
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @return The bytes for detailedHealthState.
*/
@java.lang.Override
public com.google.protobuf.ByteString getDetailedHealthStateBytes() {
java.lang.Object ref = detailedHealthState_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
detailedHealthState_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int HEALTH_CHECK_FIELD_NUMBER = 308876645;
@SuppressWarnings("serial")
private volatile java.lang.Object healthCheck_ = "";
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @return Whether the healthCheck field is set.
*/
@java.lang.Override
public boolean hasHealthCheck() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @return The healthCheck.
*/
@java.lang.Override
public java.lang.String getHealthCheck() {
java.lang.Object ref = healthCheck_;
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();
healthCheck_ = s;
return s;
}
}
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @return The bytes for healthCheck.
*/
@java.lang.Override
public com.google.protobuf.ByteString getHealthCheckBytes() {
java.lang.Object ref = healthCheck_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
healthCheck_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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_ & 0x00000002) != 0)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 308876645, healthCheck_);
}
if (((bitField0_ & 0x00000001) != 0)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 510470173, detailedHealthState_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000002) != 0)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(308876645, healthCheck_);
}
if (((bitField0_ & 0x00000001) != 0)) {
size +=
com.google.protobuf.GeneratedMessageV3.computeStringSize(510470173, detailedHealthState_);
}
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.ManagedInstanceInstanceHealth)) {
return super.equals(obj);
}
com.google.cloud.compute.v1.ManagedInstanceInstanceHealth other =
(com.google.cloud.compute.v1.ManagedInstanceInstanceHealth) obj;
if (hasDetailedHealthState() != other.hasDetailedHealthState()) return false;
if (hasDetailedHealthState()) {
if (!getDetailedHealthState().equals(other.getDetailedHealthState())) return false;
}
if (hasHealthCheck() != other.hasHealthCheck()) return false;
if (hasHealthCheck()) {
if (!getHealthCheck().equals(other.getHealthCheck())) 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 (hasDetailedHealthState()) {
hash = (37 * hash) + DETAILED_HEALTH_STATE_FIELD_NUMBER;
hash = (53 * hash) + getDetailedHealthState().hashCode();
}
if (hasHealthCheck()) {
hash = (37 * hash) + HEALTH_CHECK_FIELD_NUMBER;
hash = (53 * hash) + getHealthCheck().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.compute.v1.ManagedInstanceInstanceHealth parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.compute.v1.ManagedInstanceInstanceHealth 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.ManagedInstanceInstanceHealth parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.compute.v1.ManagedInstanceInstanceHealth 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.ManagedInstanceInstanceHealth parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.compute.v1.ManagedInstanceInstanceHealth 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.ManagedInstanceInstanceHealth parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.compute.v1.ManagedInstanceInstanceHealth 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.ManagedInstanceInstanceHealth parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.compute.v1.ManagedInstanceInstanceHealth 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.ManagedInstanceInstanceHealth 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.ManagedInstanceInstanceHealth 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.ManagedInstanceInstanceHealth 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;
}
/**
*
*
* <pre>
* </pre>
*
* Protobuf type {@code google.cloud.compute.v1.ManagedInstanceInstanceHealth}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.compute.v1.ManagedInstanceInstanceHealth)
com.google.cloud.compute.v1.ManagedInstanceInstanceHealthOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_ManagedInstanceInstanceHealth_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.compute.v1.Compute
.internal_static_google_cloud_compute_v1_ManagedInstanceInstanceHealth_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.class,
com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.Builder.class);
}
// Construct using com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
detailedHealthState_ = "";
healthCheck_ = "";
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_ManagedInstanceInstanceHealth_descriptor;
}
@java.lang.Override
public com.google.cloud.compute.v1.ManagedInstanceInstanceHealth getDefaultInstanceForType() {
return com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.compute.v1.ManagedInstanceInstanceHealth build() {
com.google.cloud.compute.v1.ManagedInstanceInstanceHealth result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.compute.v1.ManagedInstanceInstanceHealth buildPartial() {
com.google.cloud.compute.v1.ManagedInstanceInstanceHealth result =
new com.google.cloud.compute.v1.ManagedInstanceInstanceHealth(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.compute.v1.ManagedInstanceInstanceHealth result) {
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.detailedHealthState_ = detailedHealthState_;
to_bitField0_ |= 0x00000001;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.healthCheck_ = healthCheck_;
to_bitField0_ |= 0x00000002;
}
result.bitField0_ |= to_bitField0_;
}
@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.ManagedInstanceInstanceHealth) {
return mergeFrom((com.google.cloud.compute.v1.ManagedInstanceInstanceHealth) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.compute.v1.ManagedInstanceInstanceHealth other) {
if (other == com.google.cloud.compute.v1.ManagedInstanceInstanceHealth.getDefaultInstance())
return this;
if (other.hasDetailedHealthState()) {
detailedHealthState_ = other.detailedHealthState_;
bitField0_ |= 0x00000001;
onChanged();
}
if (other.hasHealthCheck()) {
healthCheck_ = other.healthCheck_;
bitField0_ |= 0x00000002;
onChanged();
}
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 -1823954134:
{
healthCheck_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case -1823954134
case -211205910:
{
detailedHealthState_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case -211205910
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.lang.Object detailedHealthState_ = "";
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @return Whether the detailedHealthState field is set.
*/
public boolean hasDetailedHealthState() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @return The detailedHealthState.
*/
public java.lang.String getDetailedHealthState() {
java.lang.Object ref = detailedHealthState_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
detailedHealthState_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @return The bytes for detailedHealthState.
*/
public com.google.protobuf.ByteString getDetailedHealthStateBytes() {
java.lang.Object ref = detailedHealthState_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
detailedHealthState_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @param value The detailedHealthState to set.
* @return This builder for chaining.
*/
public Builder setDetailedHealthState(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
detailedHealthState_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @return This builder for chaining.
*/
public Builder clearDetailedHealthState() {
detailedHealthState_ = getDefaultInstance().getDetailedHealthState();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* [Output Only] The current detailed instance health state.
* Check the DetailedHealthState enum for the list of possible values.
* </pre>
*
* <code>optional string detailed_health_state = 510470173;</code>
*
* @param value The bytes for detailedHealthState to set.
* @return This builder for chaining.
*/
public Builder setDetailedHealthStateBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
detailedHealthState_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object healthCheck_ = "";
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @return Whether the healthCheck field is set.
*/
public boolean hasHealthCheck() {
return ((bitField0_ & 0x00000002) != 0);
}
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @return The healthCheck.
*/
public java.lang.String getHealthCheck() {
java.lang.Object ref = healthCheck_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
healthCheck_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @return The bytes for healthCheck.
*/
public com.google.protobuf.ByteString getHealthCheckBytes() {
java.lang.Object ref = healthCheck_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
healthCheck_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @param value The healthCheck to set.
* @return This builder for chaining.
*/
public Builder setHealthCheck(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
healthCheck_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @return This builder for chaining.
*/
public Builder clearHealthCheck() {
healthCheck_ = getDefaultInstance().getHealthCheck();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* [Output Only] The URL for the health check that verifies whether the instance is healthy.
* </pre>
*
* <code>optional string health_check = 308876645;</code>
*
* @param value The bytes for healthCheck to set.
* @return This builder for chaining.
*/
public Builder setHealthCheckBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
healthCheck_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
@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.ManagedInstanceInstanceHealth)
}
// @@protoc_insertion_point(class_scope:google.cloud.compute.v1.ManagedInstanceInstanceHealth)
private static final com.google.cloud.compute.v1.ManagedInstanceInstanceHealth DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.compute.v1.ManagedInstanceInstanceHealth();
}
public static com.google.cloud.compute.v1.ManagedInstanceInstanceHealth getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<ManagedInstanceInstanceHealth> PARSER =
new com.google.protobuf.AbstractParser<ManagedInstanceInstanceHealth>() {
@java.lang.Override
public ManagedInstanceInstanceHealth 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<ManagedInstanceInstanceHealth> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<ManagedInstanceInstanceHealth> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.compute.v1.ManagedInstanceInstanceHealth getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
googleapis/google-api-java-client-services | 36,245 | clients/google-api-services-analytics/v3/2.0.0/com/google/api/services/analytics/model/Experiment.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.analytics.model;
/**
* JSON template for Analytics experiment resource.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Google Analytics API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Experiment extends com.google.api.client.json.GenericJson {
/**
* Account ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String accountId;
/**
* Time the experiment was created. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime created;
/**
* Notes about this experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean editableInGaUi;
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime endTime;
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean equalWeighting;
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String internalWebPropertyId;
/**
* Resource type for an Analytics experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Integer minimumExperimentLengthInDays;
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String objectiveMetric;
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String optimizationType;
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private ParentLink parentLink;
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String profileId;
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String reasonExperimentEnded;
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean rewriteVariationUrlsAsOriginal;
/**
* Link for this experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String selfLink;
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String servingFramework;
/**
* The snippet of code to include on the control page(s). This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String snippet;
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime startTime;
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double trafficCoverage;
/**
* Time the experiment was last modified. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime updated;
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.util.List<Variations> variations;
static {
// hack to force ProGuard to consider Variations used, since otherwise it would be stripped out
// see https://github.com/google/google-api-java-client/issues/543
com.google.api.client.util.Data.nullOf(Variations.class);
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String webPropertyId;
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double winnerConfidenceLevel;
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean winnerFound;
/**
* Account ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getAccountId() {
return accountId;
}
/**
* Account ID to which this experiment belongs. This field is read-only.
* @param accountId accountId or {@code null} for none
*/
public Experiment setAccountId(java.lang.String accountId) {
this.accountId = accountId;
return this;
}
/**
* Time the experiment was created. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreated() {
return created;
}
/**
* Time the experiment was created. This field is read-only.
* @param created created or {@code null} for none
*/
public Experiment setCreated(com.google.api.client.util.DateTime created) {
this.created = created;
return this;
}
/**
* Notes about this experiment.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Notes about this experiment.
* @param description description or {@code null} for none
*/
public Experiment setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEditableInGaUi() {
return editableInGaUi;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @param editableInGaUi editableInGaUi or {@code null} for none
*/
public Experiment setEditableInGaUi(java.lang.Boolean editableInGaUi) {
this.editableInGaUi = editableInGaUi;
return this;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getEndTime() {
return endTime;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @param endTime endTime or {@code null} for none
*/
public Experiment setEndTime(com.google.api.client.util.DateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEqualWeighting() {
return equalWeighting;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @param equalWeighting equalWeighting or {@code null} for none
*/
public Experiment setEqualWeighting(java.lang.Boolean equalWeighting) {
this.equalWeighting = equalWeighting;
return this;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @param id id or {@code null} for none
*/
public Experiment setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getInternalWebPropertyId() {
return internalWebPropertyId;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @param internalWebPropertyId internalWebPropertyId or {@code null} for none
*/
public Experiment setInternalWebPropertyId(java.lang.String internalWebPropertyId) {
this.internalWebPropertyId = internalWebPropertyId;
return this;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @param kind kind or {@code null} for none
*/
public Experiment setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @return value or {@code null} for none
*/
public java.lang.Integer getMinimumExperimentLengthInDays() {
return minimumExperimentLengthInDays;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @param minimumExperimentLengthInDays minimumExperimentLengthInDays or {@code null} for none
*/
public Experiment setMinimumExperimentLengthInDays(java.lang.Integer minimumExperimentLengthInDays) {
this.minimumExperimentLengthInDays = minimumExperimentLengthInDays;
return this;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @param name name or {@code null} for none
*/
public Experiment setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @return value or {@code null} for none
*/
public java.lang.String getObjectiveMetric() {
return objectiveMetric;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @param objectiveMetric objectiveMetric or {@code null} for none
*/
public Experiment setObjectiveMetric(java.lang.String objectiveMetric) {
this.objectiveMetric = objectiveMetric;
return this;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @return value or {@code null} for none
*/
public java.lang.String getOptimizationType() {
return optimizationType;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @param optimizationType optimizationType or {@code null} for none
*/
public Experiment setOptimizationType(java.lang.String optimizationType) {
this.optimizationType = optimizationType;
return this;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @return value or {@code null} for none
*/
public ParentLink getParentLink() {
return parentLink;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @param parentLink parentLink or {@code null} for none
*/
public Experiment setParentLink(ParentLink parentLink) {
this.parentLink = parentLink;
return this;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getProfileId() {
return profileId;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @param profileId profileId or {@code null} for none
*/
public Experiment setProfileId(java.lang.String profileId) {
this.profileId = profileId;
return this;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getReasonExperimentEnded() {
return reasonExperimentEnded;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @param reasonExperimentEnded reasonExperimentEnded or {@code null} for none
*/
public Experiment setReasonExperimentEnded(java.lang.String reasonExperimentEnded) {
this.reasonExperimentEnded = reasonExperimentEnded;
return this;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getRewriteVariationUrlsAsOriginal() {
return rewriteVariationUrlsAsOriginal;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @param rewriteVariationUrlsAsOriginal rewriteVariationUrlsAsOriginal or {@code null} for none
*/
public Experiment setRewriteVariationUrlsAsOriginal(java.lang.Boolean rewriteVariationUrlsAsOriginal) {
this.rewriteVariationUrlsAsOriginal = rewriteVariationUrlsAsOriginal;
return this;
}
/**
* Link for this experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSelfLink() {
return selfLink;
}
/**
* Link for this experiment. This field is read-only.
* @param selfLink selfLink or {@code null} for none
*/
public Experiment setSelfLink(java.lang.String selfLink) {
this.selfLink = selfLink;
return this;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @return value or {@code null} for none
*/
public java.lang.String getServingFramework() {
return servingFramework;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @param servingFramework servingFramework or {@code null} for none
*/
public Experiment setServingFramework(java.lang.String servingFramework) {
this.servingFramework = servingFramework;
return this;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSnippet() {
return snippet;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @param snippet snippet or {@code null} for none
*/
public Experiment setSnippet(java.lang.String snippet) {
this.snippet = snippet;
return this;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getStartTime() {
return startTime;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @param startTime startTime or {@code null} for none
*/
public Experiment setStartTime(com.google.api.client.util.DateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @param status status or {@code null} for none
*/
public Experiment setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getTrafficCoverage() {
return trafficCoverage;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @param trafficCoverage trafficCoverage or {@code null} for none
*/
public Experiment setTrafficCoverage(java.lang.Double trafficCoverage) {
this.trafficCoverage = trafficCoverage;
return this;
}
/**
* Time the experiment was last modified. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getUpdated() {
return updated;
}
/**
* Time the experiment was last modified. This field is read-only.
* @param updated updated or {@code null} for none
*/
public Experiment setUpdated(com.google.api.client.util.DateTime updated) {
this.updated = updated;
return this;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @return value or {@code null} for none
*/
public java.util.List<Variations> getVariations() {
return variations;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @param variations variations or {@code null} for none
*/
public Experiment setVariations(java.util.List<Variations> variations) {
this.variations = variations;
return this;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getWebPropertyId() {
return webPropertyId;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @param webPropertyId webPropertyId or {@code null} for none
*/
public Experiment setWebPropertyId(java.lang.String webPropertyId) {
this.webPropertyId = webPropertyId;
return this;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getWinnerConfidenceLevel() {
return winnerConfidenceLevel;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @param winnerConfidenceLevel winnerConfidenceLevel or {@code null} for none
*/
public Experiment setWinnerConfidenceLevel(java.lang.Double winnerConfidenceLevel) {
this.winnerConfidenceLevel = winnerConfidenceLevel;
return this;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWinnerFound() {
return winnerFound;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @param winnerFound winnerFound or {@code null} for none
*/
public Experiment setWinnerFound(java.lang.Boolean winnerFound) {
this.winnerFound = winnerFound;
return this;
}
@Override
public Experiment set(String fieldName, Object value) {
return (Experiment) super.set(fieldName, value);
}
@Override
public Experiment clone() {
return (Experiment) super.clone();
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
*/
public static final class ParentLink extends com.google.api.client.json.GenericJson {
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String href;
/**
* Value is "analytics#profile". This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String type;
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getHref() {
return href;
}
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @param href href or {@code null} for none
*/
public ParentLink setHref(java.lang.String href) {
this.href = href;
return this;
}
/**
* Value is "analytics#profile". This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getType() {
return type;
}
/**
* Value is "analytics#profile". This field is read-only.
* @param type type or {@code null} for none
*/
public ParentLink setType(java.lang.String type) {
this.type = type;
return this;
}
@Override
public ParentLink set(String fieldName, Object value) {
return (ParentLink) super.set(fieldName, value);
}
@Override
public ParentLink clone() {
return (ParentLink) super.clone();
}
}
/**
* Model definition for ExperimentVariations.
*/
public static final class Variations extends com.google.api.client.json.GenericJson {
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String url;
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double weight;
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean won;
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @param name name or {@code null} for none
*/
public Variations setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @param status status or {@code null} for none
*/
public Variations setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getUrl() {
return url;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @param url url or {@code null} for none
*/
public Variations setUrl(java.lang.String url) {
this.url = url;
return this;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Double getWeight() {
return weight;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @param weight weight or {@code null} for none
*/
public Variations setWeight(java.lang.Double weight) {
this.weight = weight;
return this;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWon() {
return won;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @param won won or {@code null} for none
*/
public Variations setWon(java.lang.Boolean won) {
this.won = won;
return this;
}
@Override
public Variations set(String fieldName, Object value) {
return (Variations) super.set(fieldName, value);
}
@Override
public Variations clone() {
return (Variations) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,245 | clients/google-api-services-analytics/v3/1.26.0/com/google/api/services/analytics/model/Experiment.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.analytics.model;
/**
* JSON template for Analytics experiment resource.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Google Analytics API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Experiment extends com.google.api.client.json.GenericJson {
/**
* Account ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String accountId;
/**
* Time the experiment was created. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime created;
/**
* Notes about this experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean editableInGaUi;
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime endTime;
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean equalWeighting;
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String internalWebPropertyId;
/**
* Resource type for an Analytics experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Integer minimumExperimentLengthInDays;
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String objectiveMetric;
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String optimizationType;
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private ParentLink parentLink;
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String profileId;
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String reasonExperimentEnded;
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean rewriteVariationUrlsAsOriginal;
/**
* Link for this experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String selfLink;
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String servingFramework;
/**
* The snippet of code to include on the control page(s). This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String snippet;
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime startTime;
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double trafficCoverage;
/**
* Time the experiment was last modified. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime updated;
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.util.List<Variations> variations;
static {
// hack to force ProGuard to consider Variations used, since otherwise it would be stripped out
// see https://github.com/google/google-api-java-client/issues/543
com.google.api.client.util.Data.nullOf(Variations.class);
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String webPropertyId;
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double winnerConfidenceLevel;
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean winnerFound;
/**
* Account ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getAccountId() {
return accountId;
}
/**
* Account ID to which this experiment belongs. This field is read-only.
* @param accountId accountId or {@code null} for none
*/
public Experiment setAccountId(java.lang.String accountId) {
this.accountId = accountId;
return this;
}
/**
* Time the experiment was created. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreated() {
return created;
}
/**
* Time the experiment was created. This field is read-only.
* @param created created or {@code null} for none
*/
public Experiment setCreated(com.google.api.client.util.DateTime created) {
this.created = created;
return this;
}
/**
* Notes about this experiment.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Notes about this experiment.
* @param description description or {@code null} for none
*/
public Experiment setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEditableInGaUi() {
return editableInGaUi;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @param editableInGaUi editableInGaUi or {@code null} for none
*/
public Experiment setEditableInGaUi(java.lang.Boolean editableInGaUi) {
this.editableInGaUi = editableInGaUi;
return this;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getEndTime() {
return endTime;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @param endTime endTime or {@code null} for none
*/
public Experiment setEndTime(com.google.api.client.util.DateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEqualWeighting() {
return equalWeighting;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @param equalWeighting equalWeighting or {@code null} for none
*/
public Experiment setEqualWeighting(java.lang.Boolean equalWeighting) {
this.equalWeighting = equalWeighting;
return this;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @param id id or {@code null} for none
*/
public Experiment setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getInternalWebPropertyId() {
return internalWebPropertyId;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @param internalWebPropertyId internalWebPropertyId or {@code null} for none
*/
public Experiment setInternalWebPropertyId(java.lang.String internalWebPropertyId) {
this.internalWebPropertyId = internalWebPropertyId;
return this;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @param kind kind or {@code null} for none
*/
public Experiment setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @return value or {@code null} for none
*/
public java.lang.Integer getMinimumExperimentLengthInDays() {
return minimumExperimentLengthInDays;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @param minimumExperimentLengthInDays minimumExperimentLengthInDays or {@code null} for none
*/
public Experiment setMinimumExperimentLengthInDays(java.lang.Integer minimumExperimentLengthInDays) {
this.minimumExperimentLengthInDays = minimumExperimentLengthInDays;
return this;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @param name name or {@code null} for none
*/
public Experiment setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @return value or {@code null} for none
*/
public java.lang.String getObjectiveMetric() {
return objectiveMetric;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @param objectiveMetric objectiveMetric or {@code null} for none
*/
public Experiment setObjectiveMetric(java.lang.String objectiveMetric) {
this.objectiveMetric = objectiveMetric;
return this;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @return value or {@code null} for none
*/
public java.lang.String getOptimizationType() {
return optimizationType;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @param optimizationType optimizationType or {@code null} for none
*/
public Experiment setOptimizationType(java.lang.String optimizationType) {
this.optimizationType = optimizationType;
return this;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @return value or {@code null} for none
*/
public ParentLink getParentLink() {
return parentLink;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @param parentLink parentLink or {@code null} for none
*/
public Experiment setParentLink(ParentLink parentLink) {
this.parentLink = parentLink;
return this;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getProfileId() {
return profileId;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @param profileId profileId or {@code null} for none
*/
public Experiment setProfileId(java.lang.String profileId) {
this.profileId = profileId;
return this;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getReasonExperimentEnded() {
return reasonExperimentEnded;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @param reasonExperimentEnded reasonExperimentEnded or {@code null} for none
*/
public Experiment setReasonExperimentEnded(java.lang.String reasonExperimentEnded) {
this.reasonExperimentEnded = reasonExperimentEnded;
return this;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getRewriteVariationUrlsAsOriginal() {
return rewriteVariationUrlsAsOriginal;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @param rewriteVariationUrlsAsOriginal rewriteVariationUrlsAsOriginal or {@code null} for none
*/
public Experiment setRewriteVariationUrlsAsOriginal(java.lang.Boolean rewriteVariationUrlsAsOriginal) {
this.rewriteVariationUrlsAsOriginal = rewriteVariationUrlsAsOriginal;
return this;
}
/**
* Link for this experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSelfLink() {
return selfLink;
}
/**
* Link for this experiment. This field is read-only.
* @param selfLink selfLink or {@code null} for none
*/
public Experiment setSelfLink(java.lang.String selfLink) {
this.selfLink = selfLink;
return this;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @return value or {@code null} for none
*/
public java.lang.String getServingFramework() {
return servingFramework;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @param servingFramework servingFramework or {@code null} for none
*/
public Experiment setServingFramework(java.lang.String servingFramework) {
this.servingFramework = servingFramework;
return this;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSnippet() {
return snippet;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @param snippet snippet or {@code null} for none
*/
public Experiment setSnippet(java.lang.String snippet) {
this.snippet = snippet;
return this;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getStartTime() {
return startTime;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @param startTime startTime or {@code null} for none
*/
public Experiment setStartTime(com.google.api.client.util.DateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @param status status or {@code null} for none
*/
public Experiment setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getTrafficCoverage() {
return trafficCoverage;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @param trafficCoverage trafficCoverage or {@code null} for none
*/
public Experiment setTrafficCoverage(java.lang.Double trafficCoverage) {
this.trafficCoverage = trafficCoverage;
return this;
}
/**
* Time the experiment was last modified. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getUpdated() {
return updated;
}
/**
* Time the experiment was last modified. This field is read-only.
* @param updated updated or {@code null} for none
*/
public Experiment setUpdated(com.google.api.client.util.DateTime updated) {
this.updated = updated;
return this;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @return value or {@code null} for none
*/
public java.util.List<Variations> getVariations() {
return variations;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @param variations variations or {@code null} for none
*/
public Experiment setVariations(java.util.List<Variations> variations) {
this.variations = variations;
return this;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getWebPropertyId() {
return webPropertyId;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @param webPropertyId webPropertyId or {@code null} for none
*/
public Experiment setWebPropertyId(java.lang.String webPropertyId) {
this.webPropertyId = webPropertyId;
return this;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getWinnerConfidenceLevel() {
return winnerConfidenceLevel;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @param winnerConfidenceLevel winnerConfidenceLevel or {@code null} for none
*/
public Experiment setWinnerConfidenceLevel(java.lang.Double winnerConfidenceLevel) {
this.winnerConfidenceLevel = winnerConfidenceLevel;
return this;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWinnerFound() {
return winnerFound;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @param winnerFound winnerFound or {@code null} for none
*/
public Experiment setWinnerFound(java.lang.Boolean winnerFound) {
this.winnerFound = winnerFound;
return this;
}
@Override
public Experiment set(String fieldName, Object value) {
return (Experiment) super.set(fieldName, value);
}
@Override
public Experiment clone() {
return (Experiment) super.clone();
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
*/
public static final class ParentLink extends com.google.api.client.json.GenericJson {
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String href;
/**
* Value is "analytics#profile". This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String type;
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getHref() {
return href;
}
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @param href href or {@code null} for none
*/
public ParentLink setHref(java.lang.String href) {
this.href = href;
return this;
}
/**
* Value is "analytics#profile". This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getType() {
return type;
}
/**
* Value is "analytics#profile". This field is read-only.
* @param type type or {@code null} for none
*/
public ParentLink setType(java.lang.String type) {
this.type = type;
return this;
}
@Override
public ParentLink set(String fieldName, Object value) {
return (ParentLink) super.set(fieldName, value);
}
@Override
public ParentLink clone() {
return (ParentLink) super.clone();
}
}
/**
* Model definition for ExperimentVariations.
*/
public static final class Variations extends com.google.api.client.json.GenericJson {
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String url;
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double weight;
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean won;
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @param name name or {@code null} for none
*/
public Variations setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @param status status or {@code null} for none
*/
public Variations setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getUrl() {
return url;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @param url url or {@code null} for none
*/
public Variations setUrl(java.lang.String url) {
this.url = url;
return this;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Double getWeight() {
return weight;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @param weight weight or {@code null} for none
*/
public Variations setWeight(java.lang.Double weight) {
this.weight = weight;
return this;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWon() {
return won;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @param won won or {@code null} for none
*/
public Variations setWon(java.lang.Boolean won) {
this.won = won;
return this;
}
@Override
public Variations set(String fieldName, Object value) {
return (Variations) super.set(fieldName, value);
}
@Override
public Variations clone() {
return (Variations) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,245 | clients/google-api-services-analytics/v3/1.27.0/com/google/api/services/analytics/model/Experiment.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.analytics.model;
/**
* JSON template for Analytics experiment resource.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Google Analytics API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Experiment extends com.google.api.client.json.GenericJson {
/**
* Account ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String accountId;
/**
* Time the experiment was created. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime created;
/**
* Notes about this experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean editableInGaUi;
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime endTime;
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean equalWeighting;
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String internalWebPropertyId;
/**
* Resource type for an Analytics experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Integer minimumExperimentLengthInDays;
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String objectiveMetric;
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String optimizationType;
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private ParentLink parentLink;
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String profileId;
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String reasonExperimentEnded;
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean rewriteVariationUrlsAsOriginal;
/**
* Link for this experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String selfLink;
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String servingFramework;
/**
* The snippet of code to include on the control page(s). This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String snippet;
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime startTime;
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double trafficCoverage;
/**
* Time the experiment was last modified. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime updated;
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.util.List<Variations> variations;
static {
// hack to force ProGuard to consider Variations used, since otherwise it would be stripped out
// see https://github.com/google/google-api-java-client/issues/543
com.google.api.client.util.Data.nullOf(Variations.class);
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String webPropertyId;
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double winnerConfidenceLevel;
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean winnerFound;
/**
* Account ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getAccountId() {
return accountId;
}
/**
* Account ID to which this experiment belongs. This field is read-only.
* @param accountId accountId or {@code null} for none
*/
public Experiment setAccountId(java.lang.String accountId) {
this.accountId = accountId;
return this;
}
/**
* Time the experiment was created. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreated() {
return created;
}
/**
* Time the experiment was created. This field is read-only.
* @param created created or {@code null} for none
*/
public Experiment setCreated(com.google.api.client.util.DateTime created) {
this.created = created;
return this;
}
/**
* Notes about this experiment.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Notes about this experiment.
* @param description description or {@code null} for none
*/
public Experiment setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEditableInGaUi() {
return editableInGaUi;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @param editableInGaUi editableInGaUi or {@code null} for none
*/
public Experiment setEditableInGaUi(java.lang.Boolean editableInGaUi) {
this.editableInGaUi = editableInGaUi;
return this;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getEndTime() {
return endTime;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @param endTime endTime or {@code null} for none
*/
public Experiment setEndTime(com.google.api.client.util.DateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEqualWeighting() {
return equalWeighting;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @param equalWeighting equalWeighting or {@code null} for none
*/
public Experiment setEqualWeighting(java.lang.Boolean equalWeighting) {
this.equalWeighting = equalWeighting;
return this;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @param id id or {@code null} for none
*/
public Experiment setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getInternalWebPropertyId() {
return internalWebPropertyId;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @param internalWebPropertyId internalWebPropertyId or {@code null} for none
*/
public Experiment setInternalWebPropertyId(java.lang.String internalWebPropertyId) {
this.internalWebPropertyId = internalWebPropertyId;
return this;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @param kind kind or {@code null} for none
*/
public Experiment setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @return value or {@code null} for none
*/
public java.lang.Integer getMinimumExperimentLengthInDays() {
return minimumExperimentLengthInDays;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @param minimumExperimentLengthInDays minimumExperimentLengthInDays or {@code null} for none
*/
public Experiment setMinimumExperimentLengthInDays(java.lang.Integer minimumExperimentLengthInDays) {
this.minimumExperimentLengthInDays = minimumExperimentLengthInDays;
return this;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @param name name or {@code null} for none
*/
public Experiment setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @return value or {@code null} for none
*/
public java.lang.String getObjectiveMetric() {
return objectiveMetric;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @param objectiveMetric objectiveMetric or {@code null} for none
*/
public Experiment setObjectiveMetric(java.lang.String objectiveMetric) {
this.objectiveMetric = objectiveMetric;
return this;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @return value or {@code null} for none
*/
public java.lang.String getOptimizationType() {
return optimizationType;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @param optimizationType optimizationType or {@code null} for none
*/
public Experiment setOptimizationType(java.lang.String optimizationType) {
this.optimizationType = optimizationType;
return this;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @return value or {@code null} for none
*/
public ParentLink getParentLink() {
return parentLink;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @param parentLink parentLink or {@code null} for none
*/
public Experiment setParentLink(ParentLink parentLink) {
this.parentLink = parentLink;
return this;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getProfileId() {
return profileId;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @param profileId profileId or {@code null} for none
*/
public Experiment setProfileId(java.lang.String profileId) {
this.profileId = profileId;
return this;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getReasonExperimentEnded() {
return reasonExperimentEnded;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @param reasonExperimentEnded reasonExperimentEnded or {@code null} for none
*/
public Experiment setReasonExperimentEnded(java.lang.String reasonExperimentEnded) {
this.reasonExperimentEnded = reasonExperimentEnded;
return this;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getRewriteVariationUrlsAsOriginal() {
return rewriteVariationUrlsAsOriginal;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @param rewriteVariationUrlsAsOriginal rewriteVariationUrlsAsOriginal or {@code null} for none
*/
public Experiment setRewriteVariationUrlsAsOriginal(java.lang.Boolean rewriteVariationUrlsAsOriginal) {
this.rewriteVariationUrlsAsOriginal = rewriteVariationUrlsAsOriginal;
return this;
}
/**
* Link for this experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSelfLink() {
return selfLink;
}
/**
* Link for this experiment. This field is read-only.
* @param selfLink selfLink or {@code null} for none
*/
public Experiment setSelfLink(java.lang.String selfLink) {
this.selfLink = selfLink;
return this;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @return value or {@code null} for none
*/
public java.lang.String getServingFramework() {
return servingFramework;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @param servingFramework servingFramework or {@code null} for none
*/
public Experiment setServingFramework(java.lang.String servingFramework) {
this.servingFramework = servingFramework;
return this;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSnippet() {
return snippet;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @param snippet snippet or {@code null} for none
*/
public Experiment setSnippet(java.lang.String snippet) {
this.snippet = snippet;
return this;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getStartTime() {
return startTime;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @param startTime startTime or {@code null} for none
*/
public Experiment setStartTime(com.google.api.client.util.DateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @param status status or {@code null} for none
*/
public Experiment setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getTrafficCoverage() {
return trafficCoverage;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @param trafficCoverage trafficCoverage or {@code null} for none
*/
public Experiment setTrafficCoverage(java.lang.Double trafficCoverage) {
this.trafficCoverage = trafficCoverage;
return this;
}
/**
* Time the experiment was last modified. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getUpdated() {
return updated;
}
/**
* Time the experiment was last modified. This field is read-only.
* @param updated updated or {@code null} for none
*/
public Experiment setUpdated(com.google.api.client.util.DateTime updated) {
this.updated = updated;
return this;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @return value or {@code null} for none
*/
public java.util.List<Variations> getVariations() {
return variations;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @param variations variations or {@code null} for none
*/
public Experiment setVariations(java.util.List<Variations> variations) {
this.variations = variations;
return this;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getWebPropertyId() {
return webPropertyId;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @param webPropertyId webPropertyId or {@code null} for none
*/
public Experiment setWebPropertyId(java.lang.String webPropertyId) {
this.webPropertyId = webPropertyId;
return this;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getWinnerConfidenceLevel() {
return winnerConfidenceLevel;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @param winnerConfidenceLevel winnerConfidenceLevel or {@code null} for none
*/
public Experiment setWinnerConfidenceLevel(java.lang.Double winnerConfidenceLevel) {
this.winnerConfidenceLevel = winnerConfidenceLevel;
return this;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWinnerFound() {
return winnerFound;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @param winnerFound winnerFound or {@code null} for none
*/
public Experiment setWinnerFound(java.lang.Boolean winnerFound) {
this.winnerFound = winnerFound;
return this;
}
@Override
public Experiment set(String fieldName, Object value) {
return (Experiment) super.set(fieldName, value);
}
@Override
public Experiment clone() {
return (Experiment) super.clone();
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
*/
public static final class ParentLink extends com.google.api.client.json.GenericJson {
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String href;
/**
* Value is "analytics#profile". This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String type;
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getHref() {
return href;
}
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @param href href or {@code null} for none
*/
public ParentLink setHref(java.lang.String href) {
this.href = href;
return this;
}
/**
* Value is "analytics#profile". This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getType() {
return type;
}
/**
* Value is "analytics#profile". This field is read-only.
* @param type type or {@code null} for none
*/
public ParentLink setType(java.lang.String type) {
this.type = type;
return this;
}
@Override
public ParentLink set(String fieldName, Object value) {
return (ParentLink) super.set(fieldName, value);
}
@Override
public ParentLink clone() {
return (ParentLink) super.clone();
}
}
/**
* Model definition for ExperimentVariations.
*/
public static final class Variations extends com.google.api.client.json.GenericJson {
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String url;
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double weight;
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean won;
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @param name name or {@code null} for none
*/
public Variations setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @param status status or {@code null} for none
*/
public Variations setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getUrl() {
return url;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @param url url or {@code null} for none
*/
public Variations setUrl(java.lang.String url) {
this.url = url;
return this;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Double getWeight() {
return weight;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @param weight weight or {@code null} for none
*/
public Variations setWeight(java.lang.Double weight) {
this.weight = weight;
return this;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWon() {
return won;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @param won won or {@code null} for none
*/
public Variations setWon(java.lang.Boolean won) {
this.won = won;
return this;
}
@Override
public Variations set(String fieldName, Object value) {
return (Variations) super.set(fieldName, value);
}
@Override
public Variations clone() {
return (Variations) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,245 | clients/google-api-services-analytics/v3/1.28.0/com/google/api/services/analytics/model/Experiment.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.analytics.model;
/**
* JSON template for Analytics experiment resource.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Google Analytics API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Experiment extends com.google.api.client.json.GenericJson {
/**
* Account ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String accountId;
/**
* Time the experiment was created. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime created;
/**
* Notes about this experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean editableInGaUi;
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime endTime;
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean equalWeighting;
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String internalWebPropertyId;
/**
* Resource type for an Analytics experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Integer minimumExperimentLengthInDays;
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String objectiveMetric;
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String optimizationType;
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private ParentLink parentLink;
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String profileId;
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String reasonExperimentEnded;
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean rewriteVariationUrlsAsOriginal;
/**
* Link for this experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String selfLink;
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String servingFramework;
/**
* The snippet of code to include on the control page(s). This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String snippet;
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime startTime;
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double trafficCoverage;
/**
* Time the experiment was last modified. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime updated;
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.util.List<Variations> variations;
static {
// hack to force ProGuard to consider Variations used, since otherwise it would be stripped out
// see https://github.com/google/google-api-java-client/issues/543
com.google.api.client.util.Data.nullOf(Variations.class);
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String webPropertyId;
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double winnerConfidenceLevel;
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean winnerFound;
/**
* Account ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getAccountId() {
return accountId;
}
/**
* Account ID to which this experiment belongs. This field is read-only.
* @param accountId accountId or {@code null} for none
*/
public Experiment setAccountId(java.lang.String accountId) {
this.accountId = accountId;
return this;
}
/**
* Time the experiment was created. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreated() {
return created;
}
/**
* Time the experiment was created. This field is read-only.
* @param created created or {@code null} for none
*/
public Experiment setCreated(com.google.api.client.util.DateTime created) {
this.created = created;
return this;
}
/**
* Notes about this experiment.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Notes about this experiment.
* @param description description or {@code null} for none
*/
public Experiment setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEditableInGaUi() {
return editableInGaUi;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @param editableInGaUi editableInGaUi or {@code null} for none
*/
public Experiment setEditableInGaUi(java.lang.Boolean editableInGaUi) {
this.editableInGaUi = editableInGaUi;
return this;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getEndTime() {
return endTime;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @param endTime endTime or {@code null} for none
*/
public Experiment setEndTime(com.google.api.client.util.DateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEqualWeighting() {
return equalWeighting;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @param equalWeighting equalWeighting or {@code null} for none
*/
public Experiment setEqualWeighting(java.lang.Boolean equalWeighting) {
this.equalWeighting = equalWeighting;
return this;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @param id id or {@code null} for none
*/
public Experiment setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getInternalWebPropertyId() {
return internalWebPropertyId;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @param internalWebPropertyId internalWebPropertyId or {@code null} for none
*/
public Experiment setInternalWebPropertyId(java.lang.String internalWebPropertyId) {
this.internalWebPropertyId = internalWebPropertyId;
return this;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @param kind kind or {@code null} for none
*/
public Experiment setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @return value or {@code null} for none
*/
public java.lang.Integer getMinimumExperimentLengthInDays() {
return minimumExperimentLengthInDays;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @param minimumExperimentLengthInDays minimumExperimentLengthInDays or {@code null} for none
*/
public Experiment setMinimumExperimentLengthInDays(java.lang.Integer minimumExperimentLengthInDays) {
this.minimumExperimentLengthInDays = minimumExperimentLengthInDays;
return this;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @param name name or {@code null} for none
*/
public Experiment setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @return value or {@code null} for none
*/
public java.lang.String getObjectiveMetric() {
return objectiveMetric;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @param objectiveMetric objectiveMetric or {@code null} for none
*/
public Experiment setObjectiveMetric(java.lang.String objectiveMetric) {
this.objectiveMetric = objectiveMetric;
return this;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @return value or {@code null} for none
*/
public java.lang.String getOptimizationType() {
return optimizationType;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @param optimizationType optimizationType or {@code null} for none
*/
public Experiment setOptimizationType(java.lang.String optimizationType) {
this.optimizationType = optimizationType;
return this;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @return value or {@code null} for none
*/
public ParentLink getParentLink() {
return parentLink;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @param parentLink parentLink or {@code null} for none
*/
public Experiment setParentLink(ParentLink parentLink) {
this.parentLink = parentLink;
return this;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getProfileId() {
return profileId;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @param profileId profileId or {@code null} for none
*/
public Experiment setProfileId(java.lang.String profileId) {
this.profileId = profileId;
return this;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getReasonExperimentEnded() {
return reasonExperimentEnded;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @param reasonExperimentEnded reasonExperimentEnded or {@code null} for none
*/
public Experiment setReasonExperimentEnded(java.lang.String reasonExperimentEnded) {
this.reasonExperimentEnded = reasonExperimentEnded;
return this;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getRewriteVariationUrlsAsOriginal() {
return rewriteVariationUrlsAsOriginal;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @param rewriteVariationUrlsAsOriginal rewriteVariationUrlsAsOriginal or {@code null} for none
*/
public Experiment setRewriteVariationUrlsAsOriginal(java.lang.Boolean rewriteVariationUrlsAsOriginal) {
this.rewriteVariationUrlsAsOriginal = rewriteVariationUrlsAsOriginal;
return this;
}
/**
* Link for this experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSelfLink() {
return selfLink;
}
/**
* Link for this experiment. This field is read-only.
* @param selfLink selfLink or {@code null} for none
*/
public Experiment setSelfLink(java.lang.String selfLink) {
this.selfLink = selfLink;
return this;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @return value or {@code null} for none
*/
public java.lang.String getServingFramework() {
return servingFramework;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @param servingFramework servingFramework or {@code null} for none
*/
public Experiment setServingFramework(java.lang.String servingFramework) {
this.servingFramework = servingFramework;
return this;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSnippet() {
return snippet;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @param snippet snippet or {@code null} for none
*/
public Experiment setSnippet(java.lang.String snippet) {
this.snippet = snippet;
return this;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getStartTime() {
return startTime;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @param startTime startTime or {@code null} for none
*/
public Experiment setStartTime(com.google.api.client.util.DateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @param status status or {@code null} for none
*/
public Experiment setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getTrafficCoverage() {
return trafficCoverage;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @param trafficCoverage trafficCoverage or {@code null} for none
*/
public Experiment setTrafficCoverage(java.lang.Double trafficCoverage) {
this.trafficCoverage = trafficCoverage;
return this;
}
/**
* Time the experiment was last modified. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getUpdated() {
return updated;
}
/**
* Time the experiment was last modified. This field is read-only.
* @param updated updated or {@code null} for none
*/
public Experiment setUpdated(com.google.api.client.util.DateTime updated) {
this.updated = updated;
return this;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @return value or {@code null} for none
*/
public java.util.List<Variations> getVariations() {
return variations;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @param variations variations or {@code null} for none
*/
public Experiment setVariations(java.util.List<Variations> variations) {
this.variations = variations;
return this;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getWebPropertyId() {
return webPropertyId;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @param webPropertyId webPropertyId or {@code null} for none
*/
public Experiment setWebPropertyId(java.lang.String webPropertyId) {
this.webPropertyId = webPropertyId;
return this;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getWinnerConfidenceLevel() {
return winnerConfidenceLevel;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @param winnerConfidenceLevel winnerConfidenceLevel or {@code null} for none
*/
public Experiment setWinnerConfidenceLevel(java.lang.Double winnerConfidenceLevel) {
this.winnerConfidenceLevel = winnerConfidenceLevel;
return this;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWinnerFound() {
return winnerFound;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @param winnerFound winnerFound or {@code null} for none
*/
public Experiment setWinnerFound(java.lang.Boolean winnerFound) {
this.winnerFound = winnerFound;
return this;
}
@Override
public Experiment set(String fieldName, Object value) {
return (Experiment) super.set(fieldName, value);
}
@Override
public Experiment clone() {
return (Experiment) super.clone();
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
*/
public static final class ParentLink extends com.google.api.client.json.GenericJson {
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String href;
/**
* Value is "analytics#profile". This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String type;
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getHref() {
return href;
}
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @param href href or {@code null} for none
*/
public ParentLink setHref(java.lang.String href) {
this.href = href;
return this;
}
/**
* Value is "analytics#profile". This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getType() {
return type;
}
/**
* Value is "analytics#profile". This field is read-only.
* @param type type or {@code null} for none
*/
public ParentLink setType(java.lang.String type) {
this.type = type;
return this;
}
@Override
public ParentLink set(String fieldName, Object value) {
return (ParentLink) super.set(fieldName, value);
}
@Override
public ParentLink clone() {
return (ParentLink) super.clone();
}
}
/**
* Model definition for ExperimentVariations.
*/
public static final class Variations extends com.google.api.client.json.GenericJson {
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String url;
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double weight;
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean won;
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @param name name or {@code null} for none
*/
public Variations setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @param status status or {@code null} for none
*/
public Variations setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getUrl() {
return url;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @param url url or {@code null} for none
*/
public Variations setUrl(java.lang.String url) {
this.url = url;
return this;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Double getWeight() {
return weight;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @param weight weight or {@code null} for none
*/
public Variations setWeight(java.lang.Double weight) {
this.weight = weight;
return this;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWon() {
return won;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @param won won or {@code null} for none
*/
public Variations setWon(java.lang.Boolean won) {
this.won = won;
return this;
}
@Override
public Variations set(String fieldName, Object value) {
return (Variations) super.set(fieldName, value);
}
@Override
public Variations clone() {
return (Variations) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,245 | clients/google-api-services-analytics/v3/1.29.2/com/google/api/services/analytics/model/Experiment.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.analytics.model;
/**
* JSON template for Analytics experiment resource.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Google Analytics API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Experiment extends com.google.api.client.json.GenericJson {
/**
* Account ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String accountId;
/**
* Time the experiment was created. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime created;
/**
* Notes about this experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean editableInGaUi;
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime endTime;
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean equalWeighting;
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String internalWebPropertyId;
/**
* Resource type for an Analytics experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Integer minimumExperimentLengthInDays;
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String objectiveMetric;
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String optimizationType;
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private ParentLink parentLink;
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String profileId;
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String reasonExperimentEnded;
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean rewriteVariationUrlsAsOriginal;
/**
* Link for this experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String selfLink;
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String servingFramework;
/**
* The snippet of code to include on the control page(s). This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String snippet;
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime startTime;
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double trafficCoverage;
/**
* Time the experiment was last modified. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime updated;
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.util.List<Variations> variations;
static {
// hack to force ProGuard to consider Variations used, since otherwise it would be stripped out
// see https://github.com/google/google-api-java-client/issues/543
com.google.api.client.util.Data.nullOf(Variations.class);
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String webPropertyId;
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double winnerConfidenceLevel;
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean winnerFound;
/**
* Account ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getAccountId() {
return accountId;
}
/**
* Account ID to which this experiment belongs. This field is read-only.
* @param accountId accountId or {@code null} for none
*/
public Experiment setAccountId(java.lang.String accountId) {
this.accountId = accountId;
return this;
}
/**
* Time the experiment was created. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreated() {
return created;
}
/**
* Time the experiment was created. This field is read-only.
* @param created created or {@code null} for none
*/
public Experiment setCreated(com.google.api.client.util.DateTime created) {
this.created = created;
return this;
}
/**
* Notes about this experiment.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Notes about this experiment.
* @param description description or {@code null} for none
*/
public Experiment setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEditableInGaUi() {
return editableInGaUi;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @param editableInGaUi editableInGaUi or {@code null} for none
*/
public Experiment setEditableInGaUi(java.lang.Boolean editableInGaUi) {
this.editableInGaUi = editableInGaUi;
return this;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getEndTime() {
return endTime;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @param endTime endTime or {@code null} for none
*/
public Experiment setEndTime(com.google.api.client.util.DateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEqualWeighting() {
return equalWeighting;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @param equalWeighting equalWeighting or {@code null} for none
*/
public Experiment setEqualWeighting(java.lang.Boolean equalWeighting) {
this.equalWeighting = equalWeighting;
return this;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @param id id or {@code null} for none
*/
public Experiment setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getInternalWebPropertyId() {
return internalWebPropertyId;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @param internalWebPropertyId internalWebPropertyId or {@code null} for none
*/
public Experiment setInternalWebPropertyId(java.lang.String internalWebPropertyId) {
this.internalWebPropertyId = internalWebPropertyId;
return this;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @param kind kind or {@code null} for none
*/
public Experiment setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @return value or {@code null} for none
*/
public java.lang.Integer getMinimumExperimentLengthInDays() {
return minimumExperimentLengthInDays;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @param minimumExperimentLengthInDays minimumExperimentLengthInDays or {@code null} for none
*/
public Experiment setMinimumExperimentLengthInDays(java.lang.Integer minimumExperimentLengthInDays) {
this.minimumExperimentLengthInDays = minimumExperimentLengthInDays;
return this;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @param name name or {@code null} for none
*/
public Experiment setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @return value or {@code null} for none
*/
public java.lang.String getObjectiveMetric() {
return objectiveMetric;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @param objectiveMetric objectiveMetric or {@code null} for none
*/
public Experiment setObjectiveMetric(java.lang.String objectiveMetric) {
this.objectiveMetric = objectiveMetric;
return this;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @return value or {@code null} for none
*/
public java.lang.String getOptimizationType() {
return optimizationType;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @param optimizationType optimizationType or {@code null} for none
*/
public Experiment setOptimizationType(java.lang.String optimizationType) {
this.optimizationType = optimizationType;
return this;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @return value or {@code null} for none
*/
public ParentLink getParentLink() {
return parentLink;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @param parentLink parentLink or {@code null} for none
*/
public Experiment setParentLink(ParentLink parentLink) {
this.parentLink = parentLink;
return this;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getProfileId() {
return profileId;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @param profileId profileId or {@code null} for none
*/
public Experiment setProfileId(java.lang.String profileId) {
this.profileId = profileId;
return this;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getReasonExperimentEnded() {
return reasonExperimentEnded;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @param reasonExperimentEnded reasonExperimentEnded or {@code null} for none
*/
public Experiment setReasonExperimentEnded(java.lang.String reasonExperimentEnded) {
this.reasonExperimentEnded = reasonExperimentEnded;
return this;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getRewriteVariationUrlsAsOriginal() {
return rewriteVariationUrlsAsOriginal;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @param rewriteVariationUrlsAsOriginal rewriteVariationUrlsAsOriginal or {@code null} for none
*/
public Experiment setRewriteVariationUrlsAsOriginal(java.lang.Boolean rewriteVariationUrlsAsOriginal) {
this.rewriteVariationUrlsAsOriginal = rewriteVariationUrlsAsOriginal;
return this;
}
/**
* Link for this experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSelfLink() {
return selfLink;
}
/**
* Link for this experiment. This field is read-only.
* @param selfLink selfLink or {@code null} for none
*/
public Experiment setSelfLink(java.lang.String selfLink) {
this.selfLink = selfLink;
return this;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @return value or {@code null} for none
*/
public java.lang.String getServingFramework() {
return servingFramework;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @param servingFramework servingFramework or {@code null} for none
*/
public Experiment setServingFramework(java.lang.String servingFramework) {
this.servingFramework = servingFramework;
return this;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSnippet() {
return snippet;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @param snippet snippet or {@code null} for none
*/
public Experiment setSnippet(java.lang.String snippet) {
this.snippet = snippet;
return this;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getStartTime() {
return startTime;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @param startTime startTime or {@code null} for none
*/
public Experiment setStartTime(com.google.api.client.util.DateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @param status status or {@code null} for none
*/
public Experiment setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getTrafficCoverage() {
return trafficCoverage;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @param trafficCoverage trafficCoverage or {@code null} for none
*/
public Experiment setTrafficCoverage(java.lang.Double trafficCoverage) {
this.trafficCoverage = trafficCoverage;
return this;
}
/**
* Time the experiment was last modified. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getUpdated() {
return updated;
}
/**
* Time the experiment was last modified. This field is read-only.
* @param updated updated or {@code null} for none
*/
public Experiment setUpdated(com.google.api.client.util.DateTime updated) {
this.updated = updated;
return this;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @return value or {@code null} for none
*/
public java.util.List<Variations> getVariations() {
return variations;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @param variations variations or {@code null} for none
*/
public Experiment setVariations(java.util.List<Variations> variations) {
this.variations = variations;
return this;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getWebPropertyId() {
return webPropertyId;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @param webPropertyId webPropertyId or {@code null} for none
*/
public Experiment setWebPropertyId(java.lang.String webPropertyId) {
this.webPropertyId = webPropertyId;
return this;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getWinnerConfidenceLevel() {
return winnerConfidenceLevel;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @param winnerConfidenceLevel winnerConfidenceLevel or {@code null} for none
*/
public Experiment setWinnerConfidenceLevel(java.lang.Double winnerConfidenceLevel) {
this.winnerConfidenceLevel = winnerConfidenceLevel;
return this;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWinnerFound() {
return winnerFound;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @param winnerFound winnerFound or {@code null} for none
*/
public Experiment setWinnerFound(java.lang.Boolean winnerFound) {
this.winnerFound = winnerFound;
return this;
}
@Override
public Experiment set(String fieldName, Object value) {
return (Experiment) super.set(fieldName, value);
}
@Override
public Experiment clone() {
return (Experiment) super.clone();
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
*/
public static final class ParentLink extends com.google.api.client.json.GenericJson {
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String href;
/**
* Value is "analytics#profile". This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String type;
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getHref() {
return href;
}
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @param href href or {@code null} for none
*/
public ParentLink setHref(java.lang.String href) {
this.href = href;
return this;
}
/**
* Value is "analytics#profile". This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getType() {
return type;
}
/**
* Value is "analytics#profile". This field is read-only.
* @param type type or {@code null} for none
*/
public ParentLink setType(java.lang.String type) {
this.type = type;
return this;
}
@Override
public ParentLink set(String fieldName, Object value) {
return (ParentLink) super.set(fieldName, value);
}
@Override
public ParentLink clone() {
return (ParentLink) super.clone();
}
}
/**
* Model definition for ExperimentVariations.
*/
public static final class Variations extends com.google.api.client.json.GenericJson {
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String url;
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double weight;
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean won;
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @param name name or {@code null} for none
*/
public Variations setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @param status status or {@code null} for none
*/
public Variations setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getUrl() {
return url;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @param url url or {@code null} for none
*/
public Variations setUrl(java.lang.String url) {
this.url = url;
return this;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Double getWeight() {
return weight;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @param weight weight or {@code null} for none
*/
public Variations setWeight(java.lang.Double weight) {
this.weight = weight;
return this;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWon() {
return won;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @param won won or {@code null} for none
*/
public Variations setWon(java.lang.Boolean won) {
this.won = won;
return this;
}
@Override
public Variations set(String fieldName, Object value) {
return (Variations) super.set(fieldName, value);
}
@Override
public Variations clone() {
return (Variations) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,245 | clients/google-api-services-analytics/v3/1.30.1/com/google/api/services/analytics/model/Experiment.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.analytics.model;
/**
* JSON template for Analytics experiment resource.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Google Analytics API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Experiment extends com.google.api.client.json.GenericJson {
/**
* Account ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String accountId;
/**
* Time the experiment was created. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime created;
/**
* Notes about this experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean editableInGaUi;
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime endTime;
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean equalWeighting;
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String internalWebPropertyId;
/**
* Resource type for an Analytics experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Integer minimumExperimentLengthInDays;
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String objectiveMetric;
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String optimizationType;
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private ParentLink parentLink;
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String profileId;
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String reasonExperimentEnded;
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean rewriteVariationUrlsAsOriginal;
/**
* Link for this experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String selfLink;
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String servingFramework;
/**
* The snippet of code to include on the control page(s). This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String snippet;
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime startTime;
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double trafficCoverage;
/**
* Time the experiment was last modified. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime updated;
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.util.List<Variations> variations;
static {
// hack to force ProGuard to consider Variations used, since otherwise it would be stripped out
// see https://github.com/google/google-api-java-client/issues/543
com.google.api.client.util.Data.nullOf(Variations.class);
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String webPropertyId;
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double winnerConfidenceLevel;
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean winnerFound;
/**
* Account ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getAccountId() {
return accountId;
}
/**
* Account ID to which this experiment belongs. This field is read-only.
* @param accountId accountId or {@code null} for none
*/
public Experiment setAccountId(java.lang.String accountId) {
this.accountId = accountId;
return this;
}
/**
* Time the experiment was created. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreated() {
return created;
}
/**
* Time the experiment was created. This field is read-only.
* @param created created or {@code null} for none
*/
public Experiment setCreated(com.google.api.client.util.DateTime created) {
this.created = created;
return this;
}
/**
* Notes about this experiment.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Notes about this experiment.
* @param description description or {@code null} for none
*/
public Experiment setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEditableInGaUi() {
return editableInGaUi;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @param editableInGaUi editableInGaUi or {@code null} for none
*/
public Experiment setEditableInGaUi(java.lang.Boolean editableInGaUi) {
this.editableInGaUi = editableInGaUi;
return this;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getEndTime() {
return endTime;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @param endTime endTime or {@code null} for none
*/
public Experiment setEndTime(com.google.api.client.util.DateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEqualWeighting() {
return equalWeighting;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @param equalWeighting equalWeighting or {@code null} for none
*/
public Experiment setEqualWeighting(java.lang.Boolean equalWeighting) {
this.equalWeighting = equalWeighting;
return this;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @param id id or {@code null} for none
*/
public Experiment setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getInternalWebPropertyId() {
return internalWebPropertyId;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @param internalWebPropertyId internalWebPropertyId or {@code null} for none
*/
public Experiment setInternalWebPropertyId(java.lang.String internalWebPropertyId) {
this.internalWebPropertyId = internalWebPropertyId;
return this;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @param kind kind or {@code null} for none
*/
public Experiment setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @return value or {@code null} for none
*/
public java.lang.Integer getMinimumExperimentLengthInDays() {
return minimumExperimentLengthInDays;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @param minimumExperimentLengthInDays minimumExperimentLengthInDays or {@code null} for none
*/
public Experiment setMinimumExperimentLengthInDays(java.lang.Integer minimumExperimentLengthInDays) {
this.minimumExperimentLengthInDays = minimumExperimentLengthInDays;
return this;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @param name name or {@code null} for none
*/
public Experiment setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @return value or {@code null} for none
*/
public java.lang.String getObjectiveMetric() {
return objectiveMetric;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @param objectiveMetric objectiveMetric or {@code null} for none
*/
public Experiment setObjectiveMetric(java.lang.String objectiveMetric) {
this.objectiveMetric = objectiveMetric;
return this;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @return value or {@code null} for none
*/
public java.lang.String getOptimizationType() {
return optimizationType;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @param optimizationType optimizationType or {@code null} for none
*/
public Experiment setOptimizationType(java.lang.String optimizationType) {
this.optimizationType = optimizationType;
return this;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @return value or {@code null} for none
*/
public ParentLink getParentLink() {
return parentLink;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @param parentLink parentLink or {@code null} for none
*/
public Experiment setParentLink(ParentLink parentLink) {
this.parentLink = parentLink;
return this;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getProfileId() {
return profileId;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @param profileId profileId or {@code null} for none
*/
public Experiment setProfileId(java.lang.String profileId) {
this.profileId = profileId;
return this;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getReasonExperimentEnded() {
return reasonExperimentEnded;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @param reasonExperimentEnded reasonExperimentEnded or {@code null} for none
*/
public Experiment setReasonExperimentEnded(java.lang.String reasonExperimentEnded) {
this.reasonExperimentEnded = reasonExperimentEnded;
return this;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getRewriteVariationUrlsAsOriginal() {
return rewriteVariationUrlsAsOriginal;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @param rewriteVariationUrlsAsOriginal rewriteVariationUrlsAsOriginal or {@code null} for none
*/
public Experiment setRewriteVariationUrlsAsOriginal(java.lang.Boolean rewriteVariationUrlsAsOriginal) {
this.rewriteVariationUrlsAsOriginal = rewriteVariationUrlsAsOriginal;
return this;
}
/**
* Link for this experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSelfLink() {
return selfLink;
}
/**
* Link for this experiment. This field is read-only.
* @param selfLink selfLink or {@code null} for none
*/
public Experiment setSelfLink(java.lang.String selfLink) {
this.selfLink = selfLink;
return this;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @return value or {@code null} for none
*/
public java.lang.String getServingFramework() {
return servingFramework;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @param servingFramework servingFramework or {@code null} for none
*/
public Experiment setServingFramework(java.lang.String servingFramework) {
this.servingFramework = servingFramework;
return this;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSnippet() {
return snippet;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @param snippet snippet or {@code null} for none
*/
public Experiment setSnippet(java.lang.String snippet) {
this.snippet = snippet;
return this;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getStartTime() {
return startTime;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @param startTime startTime or {@code null} for none
*/
public Experiment setStartTime(com.google.api.client.util.DateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @param status status or {@code null} for none
*/
public Experiment setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getTrafficCoverage() {
return trafficCoverage;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @param trafficCoverage trafficCoverage or {@code null} for none
*/
public Experiment setTrafficCoverage(java.lang.Double trafficCoverage) {
this.trafficCoverage = trafficCoverage;
return this;
}
/**
* Time the experiment was last modified. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getUpdated() {
return updated;
}
/**
* Time the experiment was last modified. This field is read-only.
* @param updated updated or {@code null} for none
*/
public Experiment setUpdated(com.google.api.client.util.DateTime updated) {
this.updated = updated;
return this;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @return value or {@code null} for none
*/
public java.util.List<Variations> getVariations() {
return variations;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @param variations variations or {@code null} for none
*/
public Experiment setVariations(java.util.List<Variations> variations) {
this.variations = variations;
return this;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getWebPropertyId() {
return webPropertyId;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @param webPropertyId webPropertyId or {@code null} for none
*/
public Experiment setWebPropertyId(java.lang.String webPropertyId) {
this.webPropertyId = webPropertyId;
return this;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getWinnerConfidenceLevel() {
return winnerConfidenceLevel;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @param winnerConfidenceLevel winnerConfidenceLevel or {@code null} for none
*/
public Experiment setWinnerConfidenceLevel(java.lang.Double winnerConfidenceLevel) {
this.winnerConfidenceLevel = winnerConfidenceLevel;
return this;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWinnerFound() {
return winnerFound;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @param winnerFound winnerFound or {@code null} for none
*/
public Experiment setWinnerFound(java.lang.Boolean winnerFound) {
this.winnerFound = winnerFound;
return this;
}
@Override
public Experiment set(String fieldName, Object value) {
return (Experiment) super.set(fieldName, value);
}
@Override
public Experiment clone() {
return (Experiment) super.clone();
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
*/
public static final class ParentLink extends com.google.api.client.json.GenericJson {
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String href;
/**
* Value is "analytics#profile". This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String type;
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getHref() {
return href;
}
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @param href href or {@code null} for none
*/
public ParentLink setHref(java.lang.String href) {
this.href = href;
return this;
}
/**
* Value is "analytics#profile". This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getType() {
return type;
}
/**
* Value is "analytics#profile". This field is read-only.
* @param type type or {@code null} for none
*/
public ParentLink setType(java.lang.String type) {
this.type = type;
return this;
}
@Override
public ParentLink set(String fieldName, Object value) {
return (ParentLink) super.set(fieldName, value);
}
@Override
public ParentLink clone() {
return (ParentLink) super.clone();
}
}
/**
* Model definition for ExperimentVariations.
*/
public static final class Variations extends com.google.api.client.json.GenericJson {
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String url;
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double weight;
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean won;
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @param name name or {@code null} for none
*/
public Variations setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @param status status or {@code null} for none
*/
public Variations setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getUrl() {
return url;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @param url url or {@code null} for none
*/
public Variations setUrl(java.lang.String url) {
this.url = url;
return this;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Double getWeight() {
return weight;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @param weight weight or {@code null} for none
*/
public Variations setWeight(java.lang.Double weight) {
this.weight = weight;
return this;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWon() {
return won;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @param won won or {@code null} for none
*/
public Variations setWon(java.lang.Boolean won) {
this.won = won;
return this;
}
@Override
public Variations set(String fieldName, Object value) {
return (Variations) super.set(fieldName, value);
}
@Override
public Variations clone() {
return (Variations) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,245 | clients/google-api-services-analytics/v3/1.31.0/com/google/api/services/analytics/model/Experiment.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.analytics.model;
/**
* JSON template for Analytics experiment resource.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Google Analytics API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class Experiment extends com.google.api.client.json.GenericJson {
/**
* Account ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String accountId;
/**
* Time the experiment was created. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime created;
/**
* Notes about this experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String description;
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean editableInGaUi;
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime endTime;
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean equalWeighting;
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String internalWebPropertyId;
/**
* Resource type for an Analytics experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Integer minimumExperimentLengthInDays;
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String objectiveMetric;
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String optimizationType;
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private ParentLink parentLink;
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String profileId;
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String reasonExperimentEnded;
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean rewriteVariationUrlsAsOriginal;
/**
* Link for this experiment. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String selfLink;
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String servingFramework;
/**
* The snippet of code to include on the control page(s). This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String snippet;
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime startTime;
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double trafficCoverage;
/**
* Time the experiment was last modified. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime updated;
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.util.List<Variations> variations;
static {
// hack to force ProGuard to consider Variations used, since otherwise it would be stripped out
// see https://github.com/google/google-api-java-client/issues/543
com.google.api.client.util.Data.nullOf(Variations.class);
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String webPropertyId;
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double winnerConfidenceLevel;
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean winnerFound;
/**
* Account ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getAccountId() {
return accountId;
}
/**
* Account ID to which this experiment belongs. This field is read-only.
* @param accountId accountId or {@code null} for none
*/
public Experiment setAccountId(java.lang.String accountId) {
this.accountId = accountId;
return this;
}
/**
* Time the experiment was created. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreated() {
return created;
}
/**
* Time the experiment was created. This field is read-only.
* @param created created or {@code null} for none
*/
public Experiment setCreated(com.google.api.client.util.DateTime created) {
this.created = created;
return this;
}
/**
* Notes about this experiment.
* @return value or {@code null} for none
*/
public java.lang.String getDescription() {
return description;
}
/**
* Notes about this experiment.
* @param description description or {@code null} for none
*/
public Experiment setDescription(java.lang.String description) {
this.description = description;
return this;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEditableInGaUi() {
return editableInGaUi;
}
/**
* If true, the end user will be able to edit the experiment via the Google Analytics user
* interface.
* @param editableInGaUi editableInGaUi or {@code null} for none
*/
public Experiment setEditableInGaUi(java.lang.Boolean editableInGaUi) {
this.editableInGaUi = editableInGaUi;
return this;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getEndTime() {
return endTime;
}
/**
* The ending time of the experiment (the time the status changed from RUNNING to ENDED). This
* field is present only if the experiment has ended. This field is read-only.
* @param endTime endTime or {@code null} for none
*/
public Experiment setEndTime(com.google.api.client.util.DateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getEqualWeighting() {
return equalWeighting;
}
/**
* Boolean specifying whether to distribute traffic evenly across all variations. If the value is
* False, content experiments follows the default behavior of adjusting traffic dynamically based
* on variation performance. Optional -- defaults to False. This field may not be changed for an
* experiment whose status is ENDED.
* @param equalWeighting equalWeighting or {@code null} for none
*/
public Experiment setEqualWeighting(java.lang.Boolean equalWeighting) {
this.equalWeighting = equalWeighting;
return this;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* Experiment ID. Required for patch and update. Disallowed for create.
* @param id id or {@code null} for none
*/
public Experiment setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getInternalWebPropertyId() {
return internalWebPropertyId;
}
/**
* Internal ID for the web property to which this experiment belongs. This field is read-only.
* @param internalWebPropertyId internalWebPropertyId or {@code null} for none
*/
public Experiment setInternalWebPropertyId(java.lang.String internalWebPropertyId) {
this.internalWebPropertyId = internalWebPropertyId;
return this;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* Resource type for an Analytics experiment. This field is read-only.
* @param kind kind or {@code null} for none
*/
public Experiment setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @return value or {@code null} for none
*/
public java.lang.Integer getMinimumExperimentLengthInDays() {
return minimumExperimentLengthInDays;
}
/**
* An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed
* for a running experiment. This field may not be changed for an experiments whose status is
* ENDED.
* @param minimumExperimentLengthInDays minimumExperimentLengthInDays or {@code null} for none
*/
public Experiment setMinimumExperimentLengthInDays(java.lang.Integer minimumExperimentLengthInDays) {
this.minimumExperimentLengthInDays = minimumExperimentLengthInDays;
return this;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* Experiment name. This field may not be changed for an experiment whose status is ENDED. This
* field is required when creating an experiment.
* @param name name or {@code null} for none
*/
public Experiment setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @return value or {@code null} for none
*/
public java.lang.String getObjectiveMetric() {
return objectiveMetric;
}
/**
* The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions",
* "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces",
* "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is
* required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
* @param objectiveMetric objectiveMetric or {@code null} for none
*/
public Experiment setObjectiveMetric(java.lang.String objectiveMetric) {
this.objectiveMetric = objectiveMetric;
return this;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @return value or {@code null} for none
*/
public java.lang.String getOptimizationType() {
return optimizationType;
}
/**
* Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM",
* "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot
* be modified when status is "RUNNING" or "ENDED".
* @param optimizationType optimizationType or {@code null} for none
*/
public Experiment setOptimizationType(java.lang.String optimizationType) {
this.optimizationType = optimizationType;
return this;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @return value or {@code null} for none
*/
public ParentLink getParentLink() {
return parentLink;
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
* @param parentLink parentLink or {@code null} for none
*/
public Experiment setParentLink(ParentLink parentLink) {
this.parentLink = parentLink;
return this;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getProfileId() {
return profileId;
}
/**
* View (Profile) ID to which this experiment belongs. This field is read-only.
* @param profileId profileId or {@code null} for none
*/
public Experiment setProfileId(java.lang.String profileId) {
this.profileId = profileId;
return this;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getReasonExperimentEnded() {
return reasonExperimentEnded;
}
/**
* Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND",
* "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER"
* means that the experiment didn't expire but no winner was projected to be found. If the
* experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This
* field is read-only.
* @param reasonExperimentEnded reasonExperimentEnded or {@code null} for none
*/
public Experiment setReasonExperimentEnded(java.lang.String reasonExperimentEnded) {
this.reasonExperimentEnded = reasonExperimentEnded;
return this;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Boolean getRewriteVariationUrlsAsOriginal() {
return rewriteVariationUrlsAsOriginal;
}
/**
* Boolean specifying whether variations URLS are rewritten to match those of the original. This
* field may not be changed for an experiments whose status is ENDED.
* @param rewriteVariationUrlsAsOriginal rewriteVariationUrlsAsOriginal or {@code null} for none
*/
public Experiment setRewriteVariationUrlsAsOriginal(java.lang.Boolean rewriteVariationUrlsAsOriginal) {
this.rewriteVariationUrlsAsOriginal = rewriteVariationUrlsAsOriginal;
return this;
}
/**
* Link for this experiment. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSelfLink() {
return selfLink;
}
/**
* Link for this experiment. This field is read-only.
* @param selfLink selfLink or {@code null} for none
*/
public Experiment setSelfLink(java.lang.String selfLink) {
this.selfLink = selfLink;
return this;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @return value or {@code null} for none
*/
public java.lang.String getServingFramework() {
return servingFramework;
}
/**
* The framework used to serve the experiment variations and evaluate the results. One of: -
* REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen
* variation and evaluates the results. - API: Google Analytics chooses and reports the variation
* to serve and evaluates the results; the caller is responsible for serving the selected
* variation. - EXTERNAL: The variations will be served externally and the chosen variation
* reported to Google Analytics. The caller is responsible for serving the selected variation and
* evaluating the results.
* @param servingFramework servingFramework or {@code null} for none
*/
public Experiment setServingFramework(java.lang.String servingFramework) {
this.servingFramework = servingFramework;
return this;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getSnippet() {
return snippet;
}
/**
* The snippet of code to include on the control page(s). This field is read-only.
* @param snippet snippet or {@code null} for none
*/
public Experiment setSnippet(java.lang.String snippet) {
this.snippet = snippet;
return this;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getStartTime() {
return startTime;
}
/**
* The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING).
* This field is present only if the experiment has started. This field is read-only.
* @param startTime startTime or {@code null} for none
*/
public Experiment setStartTime(com.google.api.client.util.DateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments
* can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when
* creating an experiment.
* @param status status or {@code null} for none
*/
public Experiment setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getTrafficCoverage() {
return trafficCoverage;
}
/**
* A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in
* the experiment. Can be changed for a running experiment. This field may not be changed for an
* experiments whose status is ENDED.
* @param trafficCoverage trafficCoverage or {@code null} for none
*/
public Experiment setTrafficCoverage(java.lang.Double trafficCoverage) {
this.trafficCoverage = trafficCoverage;
return this;
}
/**
* Time the experiment was last modified. This field is read-only.
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getUpdated() {
return updated;
}
/**
* Time the experiment was last modified. This field is read-only.
* @param updated updated or {@code null} for none
*/
public Experiment setUpdated(com.google.api.client.util.DateTime updated) {
this.updated = updated;
return this;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @return value or {@code null} for none
*/
public java.util.List<Variations> getVariations() {
return variations;
}
/**
* Array of variations. The first variation in the array is the original. The number of variations
* may not change once an experiment is in the RUNNING state. At least two variations are required
* before status can be set to RUNNING.
* @param variations variations or {@code null} for none
*/
public Experiment setVariations(java.util.List<Variations> variations) {
this.variations = variations;
return this;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getWebPropertyId() {
return webPropertyId;
}
/**
* Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-
* YY. This field is read-only.
* @param webPropertyId webPropertyId or {@code null} for none
*/
public Experiment setWebPropertyId(java.lang.String webPropertyId) {
this.webPropertyId = webPropertyId;
return this;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.Double getWinnerConfidenceLevel() {
return winnerConfidenceLevel;
}
/**
* A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner.
* This field may not be changed for an experiments whose status is ENDED.
* @param winnerConfidenceLevel winnerConfidenceLevel or {@code null} for none
*/
public Experiment setWinnerConfidenceLevel(java.lang.Double winnerConfidenceLevel) {
this.winnerConfidenceLevel = winnerConfidenceLevel;
return this;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWinnerFound() {
return winnerFound;
}
/**
* Boolean specifying whether a winner has been found for this experiment. This field is read-
* only.
* @param winnerFound winnerFound or {@code null} for none
*/
public Experiment setWinnerFound(java.lang.Boolean winnerFound) {
this.winnerFound = winnerFound;
return this;
}
@Override
public Experiment set(String fieldName, Object value) {
return (Experiment) super.set(fieldName, value);
}
@Override
public Experiment clone() {
return (Experiment) super.clone();
}
/**
* Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
*/
public static final class ParentLink extends com.google.api.client.json.GenericJson {
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String href;
/**
* Value is "analytics#profile". This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String type;
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getHref() {
return href;
}
/**
* Link to the view (profile) to which this experiment belongs. This field is read-only.
* @param href href or {@code null} for none
*/
public ParentLink setHref(java.lang.String href) {
this.href = href;
return this;
}
/**
* Value is "analytics#profile". This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.String getType() {
return type;
}
/**
* Value is "analytics#profile". This field is read-only.
* @param type type or {@code null} for none
*/
public ParentLink setType(java.lang.String type) {
this.type = type;
return this;
}
@Override
public ParentLink set(String fieldName, Object value) {
return (ParentLink) super.set(fieldName, value);
}
@Override
public ParentLink clone() {
return (ParentLink) super.clone();
}
}
/**
* Model definition for ExperimentVariations.
*/
public static final class Variations extends com.google.api.client.json.GenericJson {
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String status;
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String url;
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Double weight;
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean won;
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of the variation. This field is required when creating an experiment. This field may
* not be changed for an experiment whose status is ENDED.
* @param name name or {@code null} for none
*/
public Variations setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getStatus() {
return status;
}
/**
* Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not
* served. This field may not be changed for an experiment whose status is ENDED.
* @param status status or {@code null} for none
*/
public Variations setStatus(java.lang.String status) {
this.status = status;
return this;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @return value or {@code null} for none
*/
public java.lang.String getUrl() {
return url;
}
/**
* The URL of the variation. This field may not be changed for an experiment whose status is
* RUNNING or ENDED.
* @param url url or {@code null} for none
*/
public Variations setUrl(java.lang.String url) {
this.url = url;
return this;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Double getWeight() {
return weight;
}
/**
* Weight that this variation should receive. Only present if the experiment is running. This
* field is read-only.
* @param weight weight or {@code null} for none
*/
public Variations setWeight(java.lang.Double weight) {
this.weight = weight;
return this;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @return value or {@code null} for none
*/
public java.lang.Boolean getWon() {
return won;
}
/**
* True if the experiment has ended and this variation performed (statistically) significantly
* better than the original. This field is read-only.
* @param won won or {@code null} for none
*/
public Variations setWon(java.lang.Boolean won) {
this.won = won;
return this;
}
@Override
public Variations set(String fieldName, Object value) {
return (Variations) super.set(fieldName, value);
}
@Override
public Variations clone() {
return (Variations) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,441 | clients/google-api-services-drive/v2/1.26.0/com/google/api/services/drive/model/TeamDrive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Deprecated: use the drive collection instead.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class TeamDrive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this Team Drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdDate;
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* This is always drive#teamDrive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public TeamDrive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this Team Drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this Team Drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public TeamDrive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this Team Drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this Team Drive.
* @param capabilities capabilities or {@code null} for none
*/
public TeamDrive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public TeamDrive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedDate() {
return createdDate;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @param createdDate createdDate or {@code null} for none
*/
public TeamDrive setCreatedDate(com.google.api.client.util.DateTime createdDate) {
this.createdDate = createdDate;
return this;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @param id id or {@code null} for none
*/
public TeamDrive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* This is always drive#teamDrive
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* This is always drive#teamDrive
* @param kind kind or {@code null} for none
*/
public TeamDrive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this Team Drive.
* @param name name or {@code null} for none
*/
public TeamDrive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @param restrictions restrictions or {@code null} for none
*/
public TeamDrive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public TeamDrive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public TeamDrive set(String fieldName, Object value) {
return (TeamDrive) super.set(fieldName, value);
}
@Override
public TeamDrive clone() {
return (TeamDrive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this Team Drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamDriveBackground;
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteTeamDrive;
/**
* Whether the current user can download files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this Team Drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRemoveChildren;
/**
* Whether the current user can rename files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameTeamDrive;
/**
* Whether the current user can share files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this Team Drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamDriveBackground() {
return canChangeTeamDriveBackground;
}
/**
* Whether the current user can change the background of this Team Drive.
* @param canChangeTeamDriveBackground canChangeTeamDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeTeamDriveBackground(java.lang.Boolean canChangeTeamDriveBackground) {
this.canChangeTeamDriveBackground = canChangeTeamDriveBackground;
return this;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamMembersOnlyRestriction() {
return canChangeTeamMembersOnlyRestriction;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @param canChangeTeamMembersOnlyRestriction canChangeTeamMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeTeamMembersOnlyRestriction(java.lang.Boolean canChangeTeamMembersOnlyRestriction) {
this.canChangeTeamMembersOnlyRestriction = canChangeTeamMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this Team Drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteTeamDrive() {
return canDeleteTeamDrive;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @param canDeleteTeamDrive canDeleteTeamDrive or {@code null} for none
*/
public Capabilities setCanDeleteTeamDrive(java.lang.Boolean canDeleteTeamDrive) {
this.canDeleteTeamDrive = canDeleteTeamDrive;
return this;
}
/**
* Whether the current user can download files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this Team Drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this Team Drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this Team Drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRemoveChildren() {
return canRemoveChildren;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @param canRemoveChildren canRemoveChildren or {@code null} for none
*/
public Capabilities setCanRemoveChildren(java.lang.Boolean canRemoveChildren) {
this.canRemoveChildren = canRemoveChildren;
return this;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameTeamDrive() {
return canRenameTeamDrive;
}
/**
* Whether the current user can rename this Team Drive.
* @param canRenameTeamDrive canRenameTeamDrive or {@code null} for none
*/
public Capabilities setCanRenameTeamDrive(java.lang.Boolean canRenameTeamDrive) {
this.canRenameTeamDrive = canRenameTeamDrive;
return this;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean teamMembersOnly;
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getTeamMembersOnly() {
return teamMembersOnly;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @param teamMembersOnly teamMembersOnly or {@code null} for none
*/
public Restrictions setTeamMembersOnly(java.lang.Boolean teamMembersOnly) {
this.teamMembersOnly = teamMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,441 | clients/google-api-services-drive/v2/1.27.0/com/google/api/services/drive/model/TeamDrive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Deprecated: use the drive collection instead.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class TeamDrive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this Team Drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdDate;
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* This is always drive#teamDrive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public TeamDrive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this Team Drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this Team Drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public TeamDrive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this Team Drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this Team Drive.
* @param capabilities capabilities or {@code null} for none
*/
public TeamDrive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public TeamDrive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedDate() {
return createdDate;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @param createdDate createdDate or {@code null} for none
*/
public TeamDrive setCreatedDate(com.google.api.client.util.DateTime createdDate) {
this.createdDate = createdDate;
return this;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @param id id or {@code null} for none
*/
public TeamDrive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* This is always drive#teamDrive
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* This is always drive#teamDrive
* @param kind kind or {@code null} for none
*/
public TeamDrive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this Team Drive.
* @param name name or {@code null} for none
*/
public TeamDrive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @param restrictions restrictions or {@code null} for none
*/
public TeamDrive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public TeamDrive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public TeamDrive set(String fieldName, Object value) {
return (TeamDrive) super.set(fieldName, value);
}
@Override
public TeamDrive clone() {
return (TeamDrive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this Team Drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamDriveBackground;
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteTeamDrive;
/**
* Whether the current user can download files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this Team Drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRemoveChildren;
/**
* Whether the current user can rename files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameTeamDrive;
/**
* Whether the current user can share files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this Team Drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamDriveBackground() {
return canChangeTeamDriveBackground;
}
/**
* Whether the current user can change the background of this Team Drive.
* @param canChangeTeamDriveBackground canChangeTeamDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeTeamDriveBackground(java.lang.Boolean canChangeTeamDriveBackground) {
this.canChangeTeamDriveBackground = canChangeTeamDriveBackground;
return this;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamMembersOnlyRestriction() {
return canChangeTeamMembersOnlyRestriction;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @param canChangeTeamMembersOnlyRestriction canChangeTeamMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeTeamMembersOnlyRestriction(java.lang.Boolean canChangeTeamMembersOnlyRestriction) {
this.canChangeTeamMembersOnlyRestriction = canChangeTeamMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this Team Drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteTeamDrive() {
return canDeleteTeamDrive;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @param canDeleteTeamDrive canDeleteTeamDrive or {@code null} for none
*/
public Capabilities setCanDeleteTeamDrive(java.lang.Boolean canDeleteTeamDrive) {
this.canDeleteTeamDrive = canDeleteTeamDrive;
return this;
}
/**
* Whether the current user can download files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this Team Drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this Team Drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this Team Drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRemoveChildren() {
return canRemoveChildren;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @param canRemoveChildren canRemoveChildren or {@code null} for none
*/
public Capabilities setCanRemoveChildren(java.lang.Boolean canRemoveChildren) {
this.canRemoveChildren = canRemoveChildren;
return this;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameTeamDrive() {
return canRenameTeamDrive;
}
/**
* Whether the current user can rename this Team Drive.
* @param canRenameTeamDrive canRenameTeamDrive or {@code null} for none
*/
public Capabilities setCanRenameTeamDrive(java.lang.Boolean canRenameTeamDrive) {
this.canRenameTeamDrive = canRenameTeamDrive;
return this;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean teamMembersOnly;
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getTeamMembersOnly() {
return teamMembersOnly;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @param teamMembersOnly teamMembersOnly or {@code null} for none
*/
public Restrictions setTeamMembersOnly(java.lang.Boolean teamMembersOnly) {
this.teamMembersOnly = teamMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,441 | clients/google-api-services-drive/v2/1.28.0/com/google/api/services/drive/model/TeamDrive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Deprecated: use the drive collection instead.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class TeamDrive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this Team Drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdDate;
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* This is always drive#teamDrive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public TeamDrive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this Team Drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this Team Drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public TeamDrive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this Team Drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this Team Drive.
* @param capabilities capabilities or {@code null} for none
*/
public TeamDrive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public TeamDrive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedDate() {
return createdDate;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @param createdDate createdDate or {@code null} for none
*/
public TeamDrive setCreatedDate(com.google.api.client.util.DateTime createdDate) {
this.createdDate = createdDate;
return this;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @param id id or {@code null} for none
*/
public TeamDrive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* This is always drive#teamDrive
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* This is always drive#teamDrive
* @param kind kind or {@code null} for none
*/
public TeamDrive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this Team Drive.
* @param name name or {@code null} for none
*/
public TeamDrive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @param restrictions restrictions or {@code null} for none
*/
public TeamDrive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public TeamDrive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public TeamDrive set(String fieldName, Object value) {
return (TeamDrive) super.set(fieldName, value);
}
@Override
public TeamDrive clone() {
return (TeamDrive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this Team Drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamDriveBackground;
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteTeamDrive;
/**
* Whether the current user can download files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this Team Drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRemoveChildren;
/**
* Whether the current user can rename files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameTeamDrive;
/**
* Whether the current user can share files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this Team Drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamDriveBackground() {
return canChangeTeamDriveBackground;
}
/**
* Whether the current user can change the background of this Team Drive.
* @param canChangeTeamDriveBackground canChangeTeamDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeTeamDriveBackground(java.lang.Boolean canChangeTeamDriveBackground) {
this.canChangeTeamDriveBackground = canChangeTeamDriveBackground;
return this;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamMembersOnlyRestriction() {
return canChangeTeamMembersOnlyRestriction;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @param canChangeTeamMembersOnlyRestriction canChangeTeamMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeTeamMembersOnlyRestriction(java.lang.Boolean canChangeTeamMembersOnlyRestriction) {
this.canChangeTeamMembersOnlyRestriction = canChangeTeamMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this Team Drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteTeamDrive() {
return canDeleteTeamDrive;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @param canDeleteTeamDrive canDeleteTeamDrive or {@code null} for none
*/
public Capabilities setCanDeleteTeamDrive(java.lang.Boolean canDeleteTeamDrive) {
this.canDeleteTeamDrive = canDeleteTeamDrive;
return this;
}
/**
* Whether the current user can download files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this Team Drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this Team Drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this Team Drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRemoveChildren() {
return canRemoveChildren;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @param canRemoveChildren canRemoveChildren or {@code null} for none
*/
public Capabilities setCanRemoveChildren(java.lang.Boolean canRemoveChildren) {
this.canRemoveChildren = canRemoveChildren;
return this;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameTeamDrive() {
return canRenameTeamDrive;
}
/**
* Whether the current user can rename this Team Drive.
* @param canRenameTeamDrive canRenameTeamDrive or {@code null} for none
*/
public Capabilities setCanRenameTeamDrive(java.lang.Boolean canRenameTeamDrive) {
this.canRenameTeamDrive = canRenameTeamDrive;
return this;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean teamMembersOnly;
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getTeamMembersOnly() {
return teamMembersOnly;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @param teamMembersOnly teamMembersOnly or {@code null} for none
*/
public Restrictions setTeamMembersOnly(java.lang.Boolean teamMembersOnly) {
this.teamMembersOnly = teamMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,441 | clients/google-api-services-drive/v2/1.29.2/com/google/api/services/drive/model/TeamDrive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Deprecated: use the drive collection instead.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class TeamDrive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this Team Drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdDate;
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* This is always drive#teamDrive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public TeamDrive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this Team Drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this Team Drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public TeamDrive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this Team Drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this Team Drive.
* @param capabilities capabilities or {@code null} for none
*/
public TeamDrive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public TeamDrive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedDate() {
return createdDate;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @param createdDate createdDate or {@code null} for none
*/
public TeamDrive setCreatedDate(com.google.api.client.util.DateTime createdDate) {
this.createdDate = createdDate;
return this;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @param id id or {@code null} for none
*/
public TeamDrive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* This is always drive#teamDrive
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* This is always drive#teamDrive
* @param kind kind or {@code null} for none
*/
public TeamDrive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this Team Drive.
* @param name name or {@code null} for none
*/
public TeamDrive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @param restrictions restrictions or {@code null} for none
*/
public TeamDrive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public TeamDrive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public TeamDrive set(String fieldName, Object value) {
return (TeamDrive) super.set(fieldName, value);
}
@Override
public TeamDrive clone() {
return (TeamDrive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this Team Drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamDriveBackground;
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteTeamDrive;
/**
* Whether the current user can download files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this Team Drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRemoveChildren;
/**
* Whether the current user can rename files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameTeamDrive;
/**
* Whether the current user can share files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this Team Drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamDriveBackground() {
return canChangeTeamDriveBackground;
}
/**
* Whether the current user can change the background of this Team Drive.
* @param canChangeTeamDriveBackground canChangeTeamDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeTeamDriveBackground(java.lang.Boolean canChangeTeamDriveBackground) {
this.canChangeTeamDriveBackground = canChangeTeamDriveBackground;
return this;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamMembersOnlyRestriction() {
return canChangeTeamMembersOnlyRestriction;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @param canChangeTeamMembersOnlyRestriction canChangeTeamMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeTeamMembersOnlyRestriction(java.lang.Boolean canChangeTeamMembersOnlyRestriction) {
this.canChangeTeamMembersOnlyRestriction = canChangeTeamMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this Team Drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteTeamDrive() {
return canDeleteTeamDrive;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @param canDeleteTeamDrive canDeleteTeamDrive or {@code null} for none
*/
public Capabilities setCanDeleteTeamDrive(java.lang.Boolean canDeleteTeamDrive) {
this.canDeleteTeamDrive = canDeleteTeamDrive;
return this;
}
/**
* Whether the current user can download files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this Team Drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this Team Drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this Team Drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRemoveChildren() {
return canRemoveChildren;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @param canRemoveChildren canRemoveChildren or {@code null} for none
*/
public Capabilities setCanRemoveChildren(java.lang.Boolean canRemoveChildren) {
this.canRemoveChildren = canRemoveChildren;
return this;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameTeamDrive() {
return canRenameTeamDrive;
}
/**
* Whether the current user can rename this Team Drive.
* @param canRenameTeamDrive canRenameTeamDrive or {@code null} for none
*/
public Capabilities setCanRenameTeamDrive(java.lang.Boolean canRenameTeamDrive) {
this.canRenameTeamDrive = canRenameTeamDrive;
return this;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean teamMembersOnly;
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getTeamMembersOnly() {
return teamMembersOnly;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @param teamMembersOnly teamMembersOnly or {@code null} for none
*/
public Restrictions setTeamMembersOnly(java.lang.Boolean teamMembersOnly) {
this.teamMembersOnly = teamMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-api-java-client-services | 36,441 | clients/google-api-services-drive/v2/1.30.1/com/google/api/services/drive/model/TeamDrive.java | /*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/googleapis/google-api-java-client-services/
* Modify at your own risk.
*/
package com.google.api.services.drive.model;
/**
* Deprecated: use the drive collection instead.
*
* <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is
* transmitted over HTTP when working with the Drive API. For a detailed explanation see:
* <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a>
* </p>
*
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public final class TeamDrive extends com.google.api.client.json.GenericJson {
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private BackgroundImageFile backgroundImageFile;
/**
* A short-lived link to this Team Drive's background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String backgroundImageLink;
/**
* Capabilities the current user has on this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Capabilities capabilities;
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String colorRgb;
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private com.google.api.client.util.DateTime createdDate;
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* This is always drive#teamDrive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String kind;
/**
* The name of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String name;
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private Restrictions restrictions;
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String themeId;
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @return value or {@code null} for none
*/
public BackgroundImageFile getBackgroundImageFile() {
return backgroundImageFile;
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't
* set themeId. When specified, all fields of the backgroundImageFile must be set.
* @param backgroundImageFile backgroundImageFile or {@code null} for none
*/
public TeamDrive setBackgroundImageFile(BackgroundImageFile backgroundImageFile) {
this.backgroundImageFile = backgroundImageFile;
return this;
}
/**
* A short-lived link to this Team Drive's background image.
* @return value or {@code null} for none
*/
public java.lang.String getBackgroundImageLink() {
return backgroundImageLink;
}
/**
* A short-lived link to this Team Drive's background image.
* @param backgroundImageLink backgroundImageLink or {@code null} for none
*/
public TeamDrive setBackgroundImageLink(java.lang.String backgroundImageLink) {
this.backgroundImageLink = backgroundImageLink;
return this;
}
/**
* Capabilities the current user has on this Team Drive.
* @return value or {@code null} for none
*/
public Capabilities getCapabilities() {
return capabilities;
}
/**
* Capabilities the current user has on this Team Drive.
* @param capabilities capabilities or {@code null} for none
*/
public TeamDrive setCapabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @return value or {@code null} for none
*/
public java.lang.String getColorRgb() {
return colorRgb;
}
/**
* The color of this Team Drive as an RGB hex string. It can only be set on a
* drive.teamdrives.update request that does not set themeId.
* @param colorRgb colorRgb or {@code null} for none
*/
public TeamDrive setColorRgb(java.lang.String colorRgb) {
this.colorRgb = colorRgb;
return this;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @return value or {@code null} for none
*/
public com.google.api.client.util.DateTime getCreatedDate() {
return createdDate;
}
/**
* The time at which the Team Drive was created (RFC 3339 date-time).
* @param createdDate createdDate or {@code null} for none
*/
public TeamDrive setCreatedDate(com.google.api.client.util.DateTime createdDate) {
this.createdDate = createdDate;
return this;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
* @param id id or {@code null} for none
*/
public TeamDrive setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* This is always drive#teamDrive
* @return value or {@code null} for none
*/
public java.lang.String getKind() {
return kind;
}
/**
* This is always drive#teamDrive
* @param kind kind or {@code null} for none
*/
public TeamDrive setKind(java.lang.String kind) {
this.kind = kind;
return this;
}
/**
* The name of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.String getName() {
return name;
}
/**
* The name of this Team Drive.
* @param name name or {@code null} for none
*/
public TeamDrive setName(java.lang.String name) {
this.name = name;
return this;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @return value or {@code null} for none
*/
public Restrictions getRestrictions() {
return restrictions;
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
* @param restrictions restrictions or {@code null} for none
*/
public TeamDrive setRestrictions(Restrictions restrictions) {
this.restrictions = restrictions;
return this;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @return value or {@code null} for none
*/
public java.lang.String getThemeId() {
return themeId;
}
/**
* The ID of the theme from which the background image and color will be set. The set of possible
* teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a
* drive.teamdrives.insert request, a random theme is chosen from which the background image and
* color are set. This is a write-only field; it can only be set on requests that don't set
* colorRgb or backgroundImageFile.
* @param themeId themeId or {@code null} for none
*/
public TeamDrive setThemeId(java.lang.String themeId) {
this.themeId = themeId;
return this;
}
@Override
public TeamDrive set(String fieldName, Object value) {
return (TeamDrive) super.set(fieldName, value);
}
@Override
public TeamDrive clone() {
return (TeamDrive) super.clone();
}
/**
* An image file and cropping parameters from which a background image for this Team Drive is set.
* This is a write only field; it can only be set on drive.teamdrives.update requests that don't set
* themeId. When specified, all fields of the backgroundImageFile must be set.
*/
public static final class BackgroundImageFile extends com.google.api.client.json.GenericJson {
/**
* The ID of an image file in Drive to use for the background image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.String id;
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float width;
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float xCoordinate;
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Float yCoordinate;
/**
* The ID of an image file in Drive to use for the background image.
* @return value or {@code null} for none
*/
public java.lang.String getId() {
return id;
}
/**
* The ID of an image file in Drive to use for the background image.
* @param id id or {@code null} for none
*/
public BackgroundImageFile setId(java.lang.String id) {
this.id = id;
return this;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @return value or {@code null} for none
*/
public java.lang.Float getWidth() {
return width;
}
/**
* The width of the cropped image in the closed range of 0 to 1. This value represents the width
* of the cropped image divided by the width of the entire image. The height is computed by
* applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280
* pixels wide and 144 pixels high.
* @param width width or {@code null} for none
*/
public BackgroundImageFile setWidth(java.lang.Float width) {
this.width = width;
return this;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getXCoordinate() {
return xCoordinate;
}
/**
* The X coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the horizontal distance from the
* left side of the entire image to the left side of the cropping area divided by the width of the
* entire image.
* @param xCoordinate xCoordinate or {@code null} for none
*/
public BackgroundImageFile setXCoordinate(java.lang.Float xCoordinate) {
this.xCoordinate = xCoordinate;
return this;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @return value or {@code null} for none
*/
public java.lang.Float getYCoordinate() {
return yCoordinate;
}
/**
* The Y coordinate of the upper left corner of the cropping area in the background image. This is
* a value in the closed range of 0 to 1. This value represents the vertical distance from the top
* side of the entire image to the top side of the cropping area divided by the height of the
* entire image.
* @param yCoordinate yCoordinate or {@code null} for none
*/
public BackgroundImageFile setYCoordinate(java.lang.Float yCoordinate) {
this.yCoordinate = yCoordinate;
return this;
}
@Override
public BackgroundImageFile set(String fieldName, Object value) {
return (BackgroundImageFile) super.set(fieldName, value);
}
@Override
public BackgroundImageFile clone() {
return (BackgroundImageFile) super.clone();
}
}
/**
* Capabilities the current user has on this Team Drive.
*/
public static final class Capabilities extends com.google.api.client.json.GenericJson {
/**
* Whether the current user can add children to folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canAddChildren;
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction;
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeDomainUsersOnlyRestriction;
/**
* Whether the current user can change the background of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamDriveBackground;
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canChangeTeamMembersOnlyRestriction;
/**
* Whether the current user can comment on files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canComment;
/**
* Whether the current user can copy files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canCopy;
/**
* Whether the current user can delete children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteChildren;
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDeleteTeamDrive;
/**
* Whether the current user can download files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canDownload;
/**
* Whether the current user can edit files in this Team Drive
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canEdit;
/**
* Whether the current user can list the children of folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canListChildren;
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canManageMembers;
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canReadRevisions;
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRemoveChildren;
/**
* Whether the current user can rename files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRename;
/**
* Whether the current user can rename this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canRenameTeamDrive;
/**
* Whether the current user can share files or folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canShare;
/**
* Whether the current user can trash children from folders in this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean canTrashChildren;
/**
* Whether the current user can add children to folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanAddChildren() {
return canAddChildren;
}
/**
* Whether the current user can add children to folders in this Team Drive.
* @param canAddChildren canAddChildren or {@code null} for none
*/
public Capabilities setCanAddChildren(java.lang.Boolean canAddChildren) {
this.canAddChildren = canAddChildren;
return this;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeCopyRequiresWriterPermissionRestriction() {
return canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* Whether the current user can change the copyRequiresWriterPermission restriction of this Team
* Drive.
* @param canChangeCopyRequiresWriterPermissionRestriction canChangeCopyRequiresWriterPermissionRestriction or {@code null} for none
*/
public Capabilities setCanChangeCopyRequiresWriterPermissionRestriction(java.lang.Boolean canChangeCopyRequiresWriterPermissionRestriction) {
this.canChangeCopyRequiresWriterPermissionRestriction = canChangeCopyRequiresWriterPermissionRestriction;
return this;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeDomainUsersOnlyRestriction() {
return canChangeDomainUsersOnlyRestriction;
}
/**
* Whether the current user can change the domainUsersOnly restriction of this Team Drive.
* @param canChangeDomainUsersOnlyRestriction canChangeDomainUsersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeDomainUsersOnlyRestriction(java.lang.Boolean canChangeDomainUsersOnlyRestriction) {
this.canChangeDomainUsersOnlyRestriction = canChangeDomainUsersOnlyRestriction;
return this;
}
/**
* Whether the current user can change the background of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamDriveBackground() {
return canChangeTeamDriveBackground;
}
/**
* Whether the current user can change the background of this Team Drive.
* @param canChangeTeamDriveBackground canChangeTeamDriveBackground or {@code null} for none
*/
public Capabilities setCanChangeTeamDriveBackground(java.lang.Boolean canChangeTeamDriveBackground) {
this.canChangeTeamDriveBackground = canChangeTeamDriveBackground;
return this;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanChangeTeamMembersOnlyRestriction() {
return canChangeTeamMembersOnlyRestriction;
}
/**
* Whether the current user can change the teamMembersOnly restriction of this Team Drive.
* @param canChangeTeamMembersOnlyRestriction canChangeTeamMembersOnlyRestriction or {@code null} for none
*/
public Capabilities setCanChangeTeamMembersOnlyRestriction(java.lang.Boolean canChangeTeamMembersOnlyRestriction) {
this.canChangeTeamMembersOnlyRestriction = canChangeTeamMembersOnlyRestriction;
return this;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanComment() {
return canComment;
}
/**
* Whether the current user can comment on files in this Team Drive.
* @param canComment canComment or {@code null} for none
*/
public Capabilities setCanComment(java.lang.Boolean canComment) {
this.canComment = canComment;
return this;
}
/**
* Whether the current user can copy files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanCopy() {
return canCopy;
}
/**
* Whether the current user can copy files in this Team Drive.
* @param canCopy canCopy or {@code null} for none
*/
public Capabilities setCanCopy(java.lang.Boolean canCopy) {
this.canCopy = canCopy;
return this;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteChildren() {
return canDeleteChildren;
}
/**
* Whether the current user can delete children from folders in this Team Drive.
* @param canDeleteChildren canDeleteChildren or {@code null} for none
*/
public Capabilities setCanDeleteChildren(java.lang.Boolean canDeleteChildren) {
this.canDeleteChildren = canDeleteChildren;
return this;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDeleteTeamDrive() {
return canDeleteTeamDrive;
}
/**
* Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may
* still fail if there are untrashed items inside the Team Drive.
* @param canDeleteTeamDrive canDeleteTeamDrive or {@code null} for none
*/
public Capabilities setCanDeleteTeamDrive(java.lang.Boolean canDeleteTeamDrive) {
this.canDeleteTeamDrive = canDeleteTeamDrive;
return this;
}
/**
* Whether the current user can download files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanDownload() {
return canDownload;
}
/**
* Whether the current user can download files in this Team Drive.
* @param canDownload canDownload or {@code null} for none
*/
public Capabilities setCanDownload(java.lang.Boolean canDownload) {
this.canDownload = canDownload;
return this;
}
/**
* Whether the current user can edit files in this Team Drive
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanEdit() {
return canEdit;
}
/**
* Whether the current user can edit files in this Team Drive
* @param canEdit canEdit or {@code null} for none
*/
public Capabilities setCanEdit(java.lang.Boolean canEdit) {
this.canEdit = canEdit;
return this;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanListChildren() {
return canListChildren;
}
/**
* Whether the current user can list the children of folders in this Team Drive.
* @param canListChildren canListChildren or {@code null} for none
*/
public Capabilities setCanListChildren(java.lang.Boolean canListChildren) {
this.canListChildren = canListChildren;
return this;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanManageMembers() {
return canManageMembers;
}
/**
* Whether the current user can add members to this Team Drive or remove them or change their
* role.
* @param canManageMembers canManageMembers or {@code null} for none
*/
public Capabilities setCanManageMembers(java.lang.Boolean canManageMembers) {
this.canManageMembers = canManageMembers;
return this;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanReadRevisions() {
return canReadRevisions;
}
/**
* Whether the current user can read the revisions resource of files in this Team Drive.
* @param canReadRevisions canReadRevisions or {@code null} for none
*/
public Capabilities setCanReadRevisions(java.lang.Boolean canReadRevisions) {
this.canReadRevisions = canReadRevisions;
return this;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRemoveChildren() {
return canRemoveChildren;
}
/**
* Deprecated - use canDeleteChildren or canTrashChildren instead.
* @param canRemoveChildren canRemoveChildren or {@code null} for none
*/
public Capabilities setCanRemoveChildren(java.lang.Boolean canRemoveChildren) {
this.canRemoveChildren = canRemoveChildren;
return this;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRename() {
return canRename;
}
/**
* Whether the current user can rename files or folders in this Team Drive.
* @param canRename canRename or {@code null} for none
*/
public Capabilities setCanRename(java.lang.Boolean canRename) {
this.canRename = canRename;
return this;
}
/**
* Whether the current user can rename this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanRenameTeamDrive() {
return canRenameTeamDrive;
}
/**
* Whether the current user can rename this Team Drive.
* @param canRenameTeamDrive canRenameTeamDrive or {@code null} for none
*/
public Capabilities setCanRenameTeamDrive(java.lang.Boolean canRenameTeamDrive) {
this.canRenameTeamDrive = canRenameTeamDrive;
return this;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanShare() {
return canShare;
}
/**
* Whether the current user can share files or folders in this Team Drive.
* @param canShare canShare or {@code null} for none
*/
public Capabilities setCanShare(java.lang.Boolean canShare) {
this.canShare = canShare;
return this;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCanTrashChildren() {
return canTrashChildren;
}
/**
* Whether the current user can trash children from folders in this Team Drive.
* @param canTrashChildren canTrashChildren or {@code null} for none
*/
public Capabilities setCanTrashChildren(java.lang.Boolean canTrashChildren) {
this.canTrashChildren = canTrashChildren;
return this;
}
@Override
public Capabilities set(String fieldName, Object value) {
return (Capabilities) super.set(fieldName, value);
}
@Override
public Capabilities clone() {
return (Capabilities) super.clone();
}
}
/**
* A set of restrictions that apply to this Team Drive or items inside this Team Drive.
*/
public static final class Restrictions extends com.google.api.client.json.GenericJson {
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean adminManagedRestrictions;
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean copyRequiresWriterPermission;
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean domainUsersOnly;
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* The value may be {@code null}.
*/
@com.google.api.client.util.Key
private java.lang.Boolean teamMembersOnly;
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @return value or {@code null} for none
*/
public java.lang.Boolean getAdminManagedRestrictions() {
return adminManagedRestrictions;
}
/**
* Whether administrative privileges on this Team Drive are required to modify restrictions.
* @param adminManagedRestrictions adminManagedRestrictions or {@code null} for none
*/
public Restrictions setAdminManagedRestrictions(java.lang.Boolean adminManagedRestrictions) {
this.adminManagedRestrictions = adminManagedRestrictions;
return this;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getCopyRequiresWriterPermission() {
return copyRequiresWriterPermission;
}
/**
* Whether the options to copy, print, or download files inside this Team Drive, should be
* disabled for readers and commenters. When this restriction is set to true, it will override the
* similarly named field to true for any file inside this Team Drive.
* @param copyRequiresWriterPermission copyRequiresWriterPermission or {@code null} for none
*/
public Restrictions setCopyRequiresWriterPermission(java.lang.Boolean copyRequiresWriterPermission) {
this.copyRequiresWriterPermission = copyRequiresWriterPermission;
return this;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getDomainUsersOnly() {
return domainUsersOnly;
}
/**
* Whether access to this Team Drive and items inside this Team Drive is restricted to users of
* the domain to which this Team Drive belongs. This restriction may be overridden by other
* sharing policies controlled outside of this Team Drive.
* @param domainUsersOnly domainUsersOnly or {@code null} for none
*/
public Restrictions setDomainUsersOnly(java.lang.Boolean domainUsersOnly) {
this.domainUsersOnly = domainUsersOnly;
return this;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @return value or {@code null} for none
*/
public java.lang.Boolean getTeamMembersOnly() {
return teamMembersOnly;
}
/**
* Whether access to items inside this Team Drive is restricted to members of this Team Drive.
* @param teamMembersOnly teamMembersOnly or {@code null} for none
*/
public Restrictions setTeamMembersOnly(java.lang.Boolean teamMembersOnly) {
this.teamMembersOnly = teamMembersOnly;
return this;
}
@Override
public Restrictions set(String fieldName, Object value) {
return (Restrictions) super.set(fieldName, value);
}
@Override
public Restrictions clone() {
return (Restrictions) super.clone();
}
}
}
|
googleapis/google-cloud-java | 36,270 | java-filestore/proto-google-cloud-filestore-v1/src/main/java/com/google/cloud/filestore/v1/RestoreInstanceRequest.java | /*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/cloud/filestore/v1/cloud_filestore_service.proto
// Protobuf Java Version: 3.25.8
package com.google.cloud.filestore.v1;
/**
*
*
* <pre>
* RestoreInstanceRequest restores an existing instance's file share from a
* backup.
* </pre>
*
* Protobuf type {@code google.cloud.filestore.v1.RestoreInstanceRequest}
*/
public final class RestoreInstanceRequest extends com.google.protobuf.GeneratedMessageV3
implements
// @@protoc_insertion_point(message_implements:google.cloud.filestore.v1.RestoreInstanceRequest)
RestoreInstanceRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use RestoreInstanceRequest.newBuilder() to construct.
private RestoreInstanceRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private RestoreInstanceRequest() {
name_ = "";
fileShare_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
return new RestoreInstanceRequest();
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.filestore.v1.CloudFilestoreServiceProto
.internal_static_google_cloud_filestore_v1_RestoreInstanceRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.filestore.v1.CloudFilestoreServiceProto
.internal_static_google_cloud_filestore_v1_RestoreInstanceRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.filestore.v1.RestoreInstanceRequest.class,
com.google.cloud.filestore.v1.RestoreInstanceRequest.Builder.class);
}
private int sourceCase_ = 0;
@SuppressWarnings("serial")
private java.lang.Object source_;
public enum SourceCase
implements
com.google.protobuf.Internal.EnumLite,
com.google.protobuf.AbstractMessage.InternalOneOfEnum {
SOURCE_BACKUP(3),
SOURCE_NOT_SET(0);
private final int value;
private SourceCase(int value) {
this.value = value;
}
/**
* @param value The number of the enum to look for.
* @return The enum associated with the given number.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static SourceCase valueOf(int value) {
return forNumber(value);
}
public static SourceCase forNumber(int value) {
switch (value) {
case 3:
return SOURCE_BACKUP;
case 0:
return SOURCE_NOT_SET;
default:
return null;
}
}
public int getNumber() {
return this.value;
}
};
public SourceCase getSourceCase() {
return SourceCase.forNumber(sourceCase_);
}
public static final int NAME_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile java.lang.Object name_ = "";
/**
*
*
* <pre>
* Required. The resource name of the instance, in the format
* `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
* </pre>
*
* <code>
* string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The name.
*/
@java.lang.Override
public java.lang.String getName() {
java.lang.Object ref = name_;
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();
name_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. The resource name of the instance, in the format
* `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
* </pre>
*
* <code>
* string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for name.
*/
@java.lang.Override
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int FILE_SHARE_FIELD_NUMBER = 2;
@SuppressWarnings("serial")
private volatile java.lang.Object fileShare_ = "";
/**
*
*
* <pre>
* Required. Name of the file share in the Filestore instance that the backup
* is being restored to.
* </pre>
*
* <code>string file_share = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The fileShare.
*/
@java.lang.Override
public java.lang.String getFileShare() {
java.lang.Object ref = fileShare_;
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();
fileShare_ = s;
return s;
}
}
/**
*
*
* <pre>
* Required. Name of the file share in the Filestore instance that the backup
* is being restored to.
* </pre>
*
* <code>string file_share = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for fileShare.
*/
@java.lang.Override
public com.google.protobuf.ByteString getFileShareBytes() {
java.lang.Object ref = fileShare_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
fileShare_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int SOURCE_BACKUP_FIELD_NUMBER = 3;
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @return Whether the sourceBackup field is set.
*/
public boolean hasSourceBackup() {
return sourceCase_ == 3;
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @return The sourceBackup.
*/
public java.lang.String getSourceBackup() {
java.lang.Object ref = "";
if (sourceCase_ == 3) {
ref = source_;
}
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();
if (sourceCase_ == 3) {
source_ = s;
}
return s;
}
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @return The bytes for sourceBackup.
*/
public com.google.protobuf.ByteString getSourceBackupBytes() {
java.lang.Object ref = "";
if (sourceCase_ == 3) {
ref = source_;
}
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
if (sourceCase_ == 3) {
source_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(fileShare_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, fileShare_);
}
if (sourceCase_ == 3) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, source_);
}
getUnknownFields().writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(fileShare_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, fileShare_);
}
if (sourceCase_ == 3) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, source_);
}
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.filestore.v1.RestoreInstanceRequest)) {
return super.equals(obj);
}
com.google.cloud.filestore.v1.RestoreInstanceRequest other =
(com.google.cloud.filestore.v1.RestoreInstanceRequest) obj;
if (!getName().equals(other.getName())) return false;
if (!getFileShare().equals(other.getFileShare())) return false;
if (!getSourceCase().equals(other.getSourceCase())) return false;
switch (sourceCase_) {
case 3:
if (!getSourceBackup().equals(other.getSourceBackup())) return false;
break;
case 0:
default:
}
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();
hash = (37 * hash) + NAME_FIELD_NUMBER;
hash = (53 * hash) + getName().hashCode();
hash = (37 * hash) + FILE_SHARE_FIELD_NUMBER;
hash = (53 * hash) + getFileShare().hashCode();
switch (sourceCase_) {
case 3:
hash = (37 * hash) + SOURCE_BACKUP_FIELD_NUMBER;
hash = (53 * hash) + getSourceBackup().hashCode();
break;
case 0:
default:
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest parseFrom(
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest 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.filestore.v1.RestoreInstanceRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest 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.filestore.v1.RestoreInstanceRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest parseFrom(
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest parseFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest 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.filestore.v1.RestoreInstanceRequest parseDelimitedFrom(
java.io.InputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest 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.filestore.v1.RestoreInstanceRequest parseFrom(
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest 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.filestore.v1.RestoreInstanceRequest 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;
}
/**
*
*
* <pre>
* RestoreInstanceRequest restores an existing instance's file share from a
* backup.
* </pre>
*
* Protobuf type {@code google.cloud.filestore.v1.RestoreInstanceRequest}
*/
public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
implements
// @@protoc_insertion_point(builder_implements:google.cloud.filestore.v1.RestoreInstanceRequest)
com.google.cloud.filestore.v1.RestoreInstanceRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return com.google.cloud.filestore.v1.CloudFilestoreServiceProto
.internal_static_google_cloud_filestore_v1_RestoreInstanceRequest_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return com.google.cloud.filestore.v1.CloudFilestoreServiceProto
.internal_static_google_cloud_filestore_v1_RestoreInstanceRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.google.cloud.filestore.v1.RestoreInstanceRequest.class,
com.google.cloud.filestore.v1.RestoreInstanceRequest.Builder.class);
}
// Construct using com.google.cloud.filestore.v1.RestoreInstanceRequest.newBuilder()
private Builder() {}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
}
@java.lang.Override
public Builder clear() {
super.clear();
bitField0_ = 0;
name_ = "";
fileShare_ = "";
sourceCase_ = 0;
source_ = null;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return com.google.cloud.filestore.v1.CloudFilestoreServiceProto
.internal_static_google_cloud_filestore_v1_RestoreInstanceRequest_descriptor;
}
@java.lang.Override
public com.google.cloud.filestore.v1.RestoreInstanceRequest getDefaultInstanceForType() {
return com.google.cloud.filestore.v1.RestoreInstanceRequest.getDefaultInstance();
}
@java.lang.Override
public com.google.cloud.filestore.v1.RestoreInstanceRequest build() {
com.google.cloud.filestore.v1.RestoreInstanceRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public com.google.cloud.filestore.v1.RestoreInstanceRequest buildPartial() {
com.google.cloud.filestore.v1.RestoreInstanceRequest result =
new com.google.cloud.filestore.v1.RestoreInstanceRequest(this);
if (bitField0_ != 0) {
buildPartial0(result);
}
buildPartialOneofs(result);
onBuilt();
return result;
}
private void buildPartial0(com.google.cloud.filestore.v1.RestoreInstanceRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.name_ = name_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.fileShare_ = fileShare_;
}
}
private void buildPartialOneofs(com.google.cloud.filestore.v1.RestoreInstanceRequest result) {
result.sourceCase_ = sourceCase_;
result.source_ = this.source_;
}
@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.filestore.v1.RestoreInstanceRequest) {
return mergeFrom((com.google.cloud.filestore.v1.RestoreInstanceRequest) other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(com.google.cloud.filestore.v1.RestoreInstanceRequest other) {
if (other == com.google.cloud.filestore.v1.RestoreInstanceRequest.getDefaultInstance())
return this;
if (!other.getName().isEmpty()) {
name_ = other.name_;
bitField0_ |= 0x00000001;
onChanged();
}
if (!other.getFileShare().isEmpty()) {
fileShare_ = other.fileShare_;
bitField0_ |= 0x00000002;
onChanged();
}
switch (other.getSourceCase()) {
case SOURCE_BACKUP:
{
sourceCase_ = 3;
source_ = other.source_;
onChanged();
break;
}
case SOURCE_NOT_SET:
{
break;
}
}
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 10:
{
name_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 18:
{
fileShare_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
case 26:
{
java.lang.String s = input.readStringRequireUtf8();
sourceCase_ = 3;
source_ = s;
break;
} // case 26
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 sourceCase_ = 0;
private java.lang.Object source_;
public SourceCase getSourceCase() {
return SourceCase.forNumber(sourceCase_);
}
public Builder clearSource() {
sourceCase_ = 0;
source_ = null;
onChanged();
return this;
}
private int bitField0_;
private java.lang.Object name_ = "";
/**
*
*
* <pre>
* Required. The resource name of the instance, in the format
* `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
* </pre>
*
* <code>
* string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The name.
*/
public java.lang.String getName() {
java.lang.Object ref = name_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
name_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. The resource name of the instance, in the format
* `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
* </pre>
*
* <code>
* string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return The bytes for name.
*/
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = name_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
name_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. The resource name of the instance, in the format
* `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
* </pre>
*
* <code>
* string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The name to set.
* @return This builder for chaining.
*/
public Builder setName(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
name_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource name of the instance, in the format
* `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
* </pre>
*
* <code>
* string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @return This builder for chaining.
*/
public Builder clearName() {
name_ = getDefaultInstance().getName();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. The resource name of the instance, in the format
* `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
* </pre>
*
* <code>
* string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... }
* </code>
*
* @param value The bytes for name to set.
* @return This builder for chaining.
*/
public Builder setNameBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
name_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private java.lang.Object fileShare_ = "";
/**
*
*
* <pre>
* Required. Name of the file share in the Filestore instance that the backup
* is being restored to.
* </pre>
*
* <code>string file_share = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The fileShare.
*/
public java.lang.String getFileShare() {
java.lang.Object ref = fileShare_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
fileShare_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Required. Name of the file share in the Filestore instance that the backup
* is being restored to.
* </pre>
*
* <code>string file_share = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The bytes for fileShare.
*/
public com.google.protobuf.ByteString getFileShareBytes() {
java.lang.Object ref = fileShare_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
fileShare_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Required. Name of the file share in the Filestore instance that the backup
* is being restored to.
* </pre>
*
* <code>string file_share = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The fileShare to set.
* @return This builder for chaining.
*/
public Builder setFileShare(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
fileShare_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Name of the file share in the Filestore instance that the backup
* is being restored to.
* </pre>
*
* <code>string file_share = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return This builder for chaining.
*/
public Builder clearFileShare() {
fileShare_ = getDefaultInstance().getFileShare();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
return this;
}
/**
*
*
* <pre>
* Required. Name of the file share in the Filestore instance that the backup
* is being restored to.
* </pre>
*
* <code>string file_share = 2 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The bytes for fileShare to set.
* @return This builder for chaining.
*/
public Builder setFileShareBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
fileShare_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @return Whether the sourceBackup field is set.
*/
@java.lang.Override
public boolean hasSourceBackup() {
return sourceCase_ == 3;
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @return The sourceBackup.
*/
@java.lang.Override
public java.lang.String getSourceBackup() {
java.lang.Object ref = "";
if (sourceCase_ == 3) {
ref = source_;
}
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (sourceCase_ == 3) {
source_ = s;
}
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @return The bytes for sourceBackup.
*/
@java.lang.Override
public com.google.protobuf.ByteString getSourceBackupBytes() {
java.lang.Object ref = "";
if (sourceCase_ == 3) {
ref = source_;
}
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
if (sourceCase_ == 3) {
source_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @param value The sourceBackup to set.
* @return This builder for chaining.
*/
public Builder setSourceBackup(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
sourceCase_ = 3;
source_ = value;
onChanged();
return this;
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @return This builder for chaining.
*/
public Builder clearSourceBackup() {
if (sourceCase_ == 3) {
sourceCase_ = 0;
source_ = null;
onChanged();
}
return this;
}
/**
*
*
* <pre>
* The resource name of the backup, in the format
* `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
* </pre>
*
* <code>string source_backup = 3 [(.google.api.resource_reference) = { ... }</code>
*
* @param value The bytes for sourceBackup to set.
* @return This builder for chaining.
*/
public Builder setSourceBackupBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
sourceCase_ = 3;
source_ = value;
onChanged();
return this;
}
@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.filestore.v1.RestoreInstanceRequest)
}
// @@protoc_insertion_point(class_scope:google.cloud.filestore.v1.RestoreInstanceRequest)
private static final com.google.cloud.filestore.v1.RestoreInstanceRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new com.google.cloud.filestore.v1.RestoreInstanceRequest();
}
public static com.google.cloud.filestore.v1.RestoreInstanceRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<RestoreInstanceRequest> PARSER =
new com.google.protobuf.AbstractParser<RestoreInstanceRequest>() {
@java.lang.Override
public RestoreInstanceRequest 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<RestoreInstanceRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<RestoreInstanceRequest> getParserForType() {
return PARSER;
}
@java.lang.Override
public com.google.cloud.filestore.v1.RestoreInstanceRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.