Package build.buf.validate
Class Constraint.Builder
- java.lang.Object
-
- com.google.protobuf.AbstractMessageLite.Builder
-
- com.google.protobuf.AbstractMessage.Builder<BuilderT>
-
- com.google.protobuf.GeneratedMessage.Builder<Constraint.Builder>
-
- build.buf.validate.Constraint.Builder
-
- All Implemented Interfaces:
ConstraintOrBuilder,com.google.protobuf.Message.Builder,com.google.protobuf.MessageLite.Builder,com.google.protobuf.MessageLiteOrBuilder,com.google.protobuf.MessageOrBuilder,java.lang.Cloneable
- Enclosing class:
- Constraint
public static final class Constraint.Builder extends com.google.protobuf.GeneratedMessage.Builder<Constraint.Builder> implements ConstraintOrBuilder
`Constraint` represents a validation rule written in the Common Expression Language (CEL) syntax. Each Constraint includes a unique identifier, an optional error message, and the CEL expression to evaluate. For more information on CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). ```proto message Foo { option (buf.validate.message).cel = { id: "foo.bar" message: "bar must be greater than 0" expression: "this.bar > 0" }; int32 bar = 1; } ```Protobuf typebuf.validate.Constraint
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Constraintbuild()ConstraintbuildPartial()Constraint.Builderclear()Constraint.BuilderclearExpression()`expression` is the actual CEL expression that will be evaluated for validation.Constraint.BuilderclearId()`id` is a string that serves as a machine-readable name for this Constraint.Constraint.BuilderclearMessage()`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false.ConstraintgetDefaultInstanceForType()static com.google.protobuf.Descriptors.DescriptorgetDescriptor()com.google.protobuf.Descriptors.DescriptorgetDescriptorForType()java.lang.StringgetExpression()`expression` is the actual CEL expression that will be evaluated for validation.com.google.protobuf.ByteStringgetExpressionBytes()`expression` is the actual CEL expression that will be evaluated for validation.java.lang.StringgetId()`id` is a string that serves as a machine-readable name for this Constraint.com.google.protobuf.ByteStringgetIdBytes()`id` is a string that serves as a machine-readable name for this Constraint.java.lang.StringgetMessage()`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false.com.google.protobuf.ByteStringgetMessageBytes()`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false.protected com.google.protobuf.GeneratedMessage.FieldAccessorTableinternalGetFieldAccessorTable()booleanisInitialized()Constraint.BuildermergeFrom(Constraint other)Constraint.BuildermergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)Constraint.BuildermergeFrom(com.google.protobuf.Message other)Constraint.BuildersetExpression(java.lang.String value)`expression` is the actual CEL expression that will be evaluated for validation.Constraint.BuildersetExpressionBytes(com.google.protobuf.ByteString value)`expression` is the actual CEL expression that will be evaluated for validation.Constraint.BuildersetId(java.lang.String value)`id` is a string that serves as a machine-readable name for this Constraint.Constraint.BuildersetIdBytes(com.google.protobuf.ByteString value)`id` is a string that serves as a machine-readable name for this Constraint.Constraint.BuildersetMessage(java.lang.String value)`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false.Constraint.BuildersetMessageBytes(com.google.protobuf.ByteString value)`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false.-
Methods inherited from class com.google.protobuf.GeneratedMessage.Builder
addRepeatedField, clearField, clearOneof, clone, getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, getUnknownFieldSetBuilder, hasField, hasOneof, internalGetMapField, internalGetMapFieldReflection, internalGetMutableMapField, internalGetMutableMapFieldReflection, isClean, markClean, mergeUnknownFields, mergeUnknownLengthDelimitedField, mergeUnknownVarintField, newBuilderForField, onBuilt, onChanged, parseUnknownField, setField, setRepeatedField, setUnknownFields, setUnknownFieldSetBuilder, setUnknownFieldsProto3
-
Methods inherited from class com.google.protobuf.AbstractMessage.Builder
findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toString
-
Methods inherited from class com.google.protobuf.AbstractMessageLite.Builder
addAll, addAll, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, newUninitializedMessageException
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
getDescriptor
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
-
internalGetFieldAccessorTable
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
- Specified by:
internalGetFieldAccessorTablein classcom.google.protobuf.GeneratedMessage.Builder<Constraint.Builder>
-
clear
public Constraint.Builder clear()
- Specified by:
clearin interfacecom.google.protobuf.Message.Builder- Specified by:
clearin interfacecom.google.protobuf.MessageLite.Builder- Overrides:
clearin classcom.google.protobuf.GeneratedMessage.Builder<Constraint.Builder>
-
getDescriptorForType
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
- Specified by:
getDescriptorForTypein interfacecom.google.protobuf.Message.Builder- Specified by:
getDescriptorForTypein interfacecom.google.protobuf.MessageOrBuilder- Overrides:
getDescriptorForTypein classcom.google.protobuf.GeneratedMessage.Builder<Constraint.Builder>
-
getDefaultInstanceForType
public Constraint getDefaultInstanceForType()
- Specified by:
getDefaultInstanceForTypein interfacecom.google.protobuf.MessageLiteOrBuilder- Specified by:
getDefaultInstanceForTypein interfacecom.google.protobuf.MessageOrBuilder
-
build
public Constraint build()
- Specified by:
buildin interfacecom.google.protobuf.Message.Builder- Specified by:
buildin interfacecom.google.protobuf.MessageLite.Builder
-
buildPartial
public Constraint buildPartial()
- Specified by:
buildPartialin interfacecom.google.protobuf.Message.Builder- Specified by:
buildPartialin interfacecom.google.protobuf.MessageLite.Builder
-
mergeFrom
public Constraint.Builder mergeFrom(com.google.protobuf.Message other)
- Specified by:
mergeFromin interfacecom.google.protobuf.Message.Builder- Overrides:
mergeFromin classcom.google.protobuf.AbstractMessage.Builder<Constraint.Builder>
-
mergeFrom
public Constraint.Builder mergeFrom(Constraint other)
-
isInitialized
public final boolean isInitialized()
- Specified by:
isInitializedin interfacecom.google.protobuf.MessageLiteOrBuilder- Overrides:
isInitializedin classcom.google.protobuf.GeneratedMessage.Builder<Constraint.Builder>
-
mergeFrom
public Constraint.Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
- Specified by:
mergeFromin interfacecom.google.protobuf.Message.Builder- Specified by:
mergeFromin interfacecom.google.protobuf.MessageLite.Builder- Overrides:
mergeFromin classcom.google.protobuf.AbstractMessage.Builder<Constraint.Builder>- Throws:
java.io.IOException
-
getId
public java.lang.String getId()
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1;- Specified by:
getIdin interfaceConstraintOrBuilder- Returns:
- The id.
-
getIdBytes
public com.google.protobuf.ByteString getIdBytes()
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1;- Specified by:
getIdBytesin interfaceConstraintOrBuilder- Returns:
- The bytes for id.
-
setId
public Constraint.Builder setId(java.lang.String value)
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1;- Parameters:
value- The id to set.- Returns:
- This builder for chaining.
-
clearId
public Constraint.Builder clearId()
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1;- Returns:
- This builder for chaining.
-
setIdBytes
public Constraint.Builder setIdBytes(com.google.protobuf.ByteString value)
`id` is a string that serves as a machine-readable name for this Constraint. It should be unique within its scope, which could be either a message or a field.
string id = 1;- Parameters:
value- The bytes for id to set.- Returns:
- This builder for chaining.
-
getMessage
public java.lang.String getMessage()
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2;- Specified by:
getMessagein interfaceConstraintOrBuilder- Returns:
- The message.
-
getMessageBytes
public com.google.protobuf.ByteString getMessageBytes()
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2;- Specified by:
getMessageBytesin interfaceConstraintOrBuilder- Returns:
- The bytes for message.
-
setMessage
public Constraint.Builder setMessage(java.lang.String value)
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2;- Parameters:
value- The message to set.- Returns:
- This builder for chaining.
-
clearMessage
public Constraint.Builder clearMessage()
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2;- Returns:
- This builder for chaining.
-
setMessageBytes
public Constraint.Builder setMessageBytes(com.google.protobuf.ByteString value)
`message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false. If a non-empty message is provided, any strings resulting from the CEL expression evaluation are ignored.
string message = 2;- Parameters:
value- The bytes for message to set.- Returns:
- This builder for chaining.
-
getExpression
public java.lang.String getExpression()
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3;- Specified by:
getExpressionin interfaceConstraintOrBuilder- Returns:
- The expression.
-
getExpressionBytes
public com.google.protobuf.ByteString getExpressionBytes()
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3;- Specified by:
getExpressionBytesin interfaceConstraintOrBuilder- Returns:
- The bytes for expression.
-
setExpression
public Constraint.Builder setExpression(java.lang.String value)
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3;- Parameters:
value- The expression to set.- Returns:
- This builder for chaining.
-
clearExpression
public Constraint.Builder clearExpression()
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3;- Returns:
- This builder for chaining.
-
setExpressionBytes
public Constraint.Builder setExpressionBytes(com.google.protobuf.ByteString value)
`expression` is the actual CEL expression that will be evaluated for validation. This string must resolve to either a boolean or a string value. If the expression evaluates to false or a non-empty string, the validation is considered failed, and the message is rejected.
string expression = 3;- Parameters:
value- The bytes for expression to set.- Returns:
- This builder for chaining.
-
-