Class Constraint.Builder

java.lang.Object
com.google.protobuf.AbstractMessageLite.Builder
com.google.protobuf.AbstractMessage.Builder<Constraint.Builder>
com.google.protobuf.GeneratedMessageV3.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, Cloneable
Enclosing class:
Constraint

public static final class Constraint.Builder extends com.google.protobuf.GeneratedMessageV3.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 type buf.validate.Constraint
  • Method Summary

    Modifier and Type
    Method
    Description
    addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value)
     
     
     
     
    `expression` is the actual CEL expression that will be evaluated for validation.
    clearField(com.google.protobuf.Descriptors.FieldDescriptor field)
     
    `id` is a string that serves as a machine-readable name for this Constraint.
    `message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false.
    clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof)
     
     
     
    static final com.google.protobuf.Descriptors.Descriptor
     
    com.google.protobuf.Descriptors.Descriptor
     
    `expression` is the actual CEL expression that will be evaluated for validation.
    com.google.protobuf.ByteString
    `expression` is the actual CEL expression that will be evaluated for validation.
    `id` is a string that serves as a machine-readable name for this Constraint.
    com.google.protobuf.ByteString
    `id` is a string that serves as a machine-readable name for this Constraint.
    `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.ByteString
    `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.GeneratedMessageV3.FieldAccessorTable
     
    final boolean
     
     
    mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
    mergeFrom(com.google.protobuf.Message other)
     
    mergeUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
     
    `expression` is the actual CEL expression that will be evaluated for validation.
    setExpressionBytes(com.google.protobuf.ByteString value)
    `expression` is the actual CEL expression that will be evaluated for validation.
    setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value)
     
    setId(String value)
    `id` is a string that serves as a machine-readable name for this Constraint.
    setIdBytes(com.google.protobuf.ByteString value)
    `id` is a string that serves as a machine-readable name for this Constraint.
    `message` is an optional field that provides a human-readable error message for this Constraint when the CEL expression evaluates to false.
    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.
    setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, Object value)
     
    setUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
     

    Methods inherited from class com.google.protobuf.GeneratedMessageV3.Builder

    getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, getUnknownFieldSetBuilder, hasField, hasOneof, internalGetMapField, internalGetMapFieldReflection, internalGetMutableMapField, internalGetMutableMapFieldReflection, isClean, markClean, mergeUnknownLengthDelimitedField, mergeUnknownVarintField, newBuilderForField, onBuilt, onChanged, parseUnknownField, 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

    Methods inherited from interface com.google.protobuf.Message.Builder

    mergeDelimitedFrom, mergeDelimitedFrom

    Methods inherited from interface com.google.protobuf.MessageLite.Builder

    mergeFrom

    Methods inherited from interface com.google.protobuf.MessageOrBuilder

    findInitializationErrors, getAllFields, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof
  • Method Details

    • getDescriptor

      public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
    • internalGetFieldAccessorTable

      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
      Specified by:
      internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • clear

      public Constraint.Builder clear()
      Specified by:
      clear in interface com.google.protobuf.Message.Builder
      Specified by:
      clear in interface com.google.protobuf.MessageLite.Builder
      Overrides:
      clear in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • getDescriptorForType

      public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
      Specified by:
      getDescriptorForType in interface com.google.protobuf.Message.Builder
      Specified by:
      getDescriptorForType in interface com.google.protobuf.MessageOrBuilder
      Overrides:
      getDescriptorForType in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • getDefaultInstanceForType

      public Constraint getDefaultInstanceForType()
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder
    • build

      public Constraint build()
      Specified by:
      build in interface com.google.protobuf.Message.Builder
      Specified by:
      build in interface com.google.protobuf.MessageLite.Builder
    • buildPartial

      public Constraint buildPartial()
      Specified by:
      buildPartial in interface com.google.protobuf.Message.Builder
      Specified by:
      buildPartial in interface com.google.protobuf.MessageLite.Builder
    • clone

      public Constraint.Builder clone()
      Specified by:
      clone in interface com.google.protobuf.Message.Builder
      Specified by:
      clone in interface com.google.protobuf.MessageLite.Builder
      Overrides:
      clone in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • setField

      public Constraint.Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value)
      Specified by:
      setField in interface com.google.protobuf.Message.Builder
      Overrides:
      setField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • clearField

      public Constraint.Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field)
      Specified by:
      clearField in interface com.google.protobuf.Message.Builder
      Overrides:
      clearField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • clearOneof

      public Constraint.Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof)
      Specified by:
      clearOneof in interface com.google.protobuf.Message.Builder
      Overrides:
      clearOneof in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • setRepeatedField

      public Constraint.Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, Object value)
      Specified by:
      setRepeatedField in interface com.google.protobuf.Message.Builder
      Overrides:
      setRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • addRepeatedField

      public Constraint.Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value)
      Specified by:
      addRepeatedField in interface com.google.protobuf.Message.Builder
      Overrides:
      addRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • mergeFrom

      public Constraint.Builder mergeFrom(com.google.protobuf.Message other)
      Specified by:
      mergeFrom in interface com.google.protobuf.Message.Builder
      Overrides:
      mergeFrom in class com.google.protobuf.AbstractMessage.Builder<Constraint.Builder>
    • mergeFrom

      public Constraint.Builder mergeFrom(Constraint other)
    • isInitialized

      public final boolean isInitialized()
      Specified by:
      isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
      Overrides:
      isInitialized in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • mergeFrom

      public Constraint.Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
      Specified by:
      mergeFrom in interface com.google.protobuf.Message.Builder
      Specified by:
      mergeFrom in interface com.google.protobuf.MessageLite.Builder
      Overrides:
      mergeFrom in class com.google.protobuf.AbstractMessage.Builder<Constraint.Builder>
      Throws:
      IOException
    • getId

      public 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 [json_name = "id"];
      Specified by:
      getId in interface ConstraintOrBuilder
      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 [json_name = "id"];
      Specified by:
      getIdBytes in interface ConstraintOrBuilder
      Returns:
      The bytes for id.
    • setId

      public Constraint.Builder setId(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 [json_name = "id"];
      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 [json_name = "id"];
      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 [json_name = "id"];
      Parameters:
      value - The bytes for id to set.
      Returns:
      This builder for chaining.
    • getMessage

      public 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 [json_name = "message"];
      Specified by:
      getMessage in interface ConstraintOrBuilder
      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 [json_name = "message"];
      Specified by:
      getMessageBytes in interface ConstraintOrBuilder
      Returns:
      The bytes for message.
    • setMessage

      public Constraint.Builder setMessage(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 [json_name = "message"];
      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 [json_name = "message"];
      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 [json_name = "message"];
      Parameters:
      value - The bytes for message to set.
      Returns:
      This builder for chaining.
    • getExpression

      public 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 [json_name = "expression"];
      Specified by:
      getExpression in interface ConstraintOrBuilder
      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 [json_name = "expression"];
      Specified by:
      getExpressionBytes in interface ConstraintOrBuilder
      Returns:
      The bytes for expression.
    • setExpression

      public Constraint.Builder setExpression(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 [json_name = "expression"];
      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 [json_name = "expression"];
      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 [json_name = "expression"];
      Parameters:
      value - The bytes for expression to set.
      Returns:
      This builder for chaining.
    • setUnknownFields

      public final Constraint.Builder setUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
      Specified by:
      setUnknownFields in interface com.google.protobuf.Message.Builder
      Overrides:
      setUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>
    • mergeUnknownFields

      public final Constraint.Builder mergeUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
      Specified by:
      mergeUnknownFields in interface com.google.protobuf.Message.Builder
      Overrides:
      mergeUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Constraint.Builder>