Class 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 type buf.validate.Constraint
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Constraint build()  
      Constraint buildPartial()  
      Constraint.Builder clear()  
      Constraint.Builder clearExpression()
      `expression` is the actual CEL expression that will be evaluated for validation.
      Constraint.Builder clearId()
      `id` is a string that serves as a machine-readable name for this Constraint.
      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.
      Constraint getDefaultInstanceForType()  
      static com.google.protobuf.Descriptors.Descriptor getDescriptor()  
      com.google.protobuf.Descriptors.Descriptor getDescriptorForType()  
      java.lang.String getExpression()
      `expression` is the actual CEL expression that will be evaluated for validation.
      com.google.protobuf.ByteString getExpressionBytes()
      `expression` is the actual CEL expression that will be evaluated for validation.
      java.lang.String getId()
      `id` is a string that serves as a machine-readable name for this Constraint.
      com.google.protobuf.ByteString getIdBytes()
      `id` is a string that serves as a machine-readable name for this Constraint.
      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.
      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.
      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()  
      boolean isInitialized()  
      Constraint.Builder mergeFrom​(Constraint other)  
      Constraint.Builder mergeFrom​(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)  
      Constraint.Builder mergeFrom​(com.google.protobuf.Message other)  
      Constraint.Builder setExpression​(java.lang.String value)
      `expression` is the actual CEL expression that will be evaluated for validation.
      Constraint.Builder setExpressionBytes​(com.google.protobuf.ByteString value)
      `expression` is the actual CEL expression that will be evaluated for validation.
      Constraint.Builder setId​(java.lang.String value)
      `id` is a string that serves as a machine-readable name for this Constraint.
      Constraint.Builder setIdBytes​(com.google.protobuf.ByteString value)
      `id` is a string that serves as a machine-readable name for this Constraint.
      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.
      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.
      • 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
      • 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 Detail

      • getDescriptor

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

        protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
        Specified by:
        internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessage.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.GeneratedMessage.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.GeneratedMessage.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
      • 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>
      • isInitialized

        public final boolean isInitialized()
        Specified by:
        isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
        Overrides:
        isInitialized in class com.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:
        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:
        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:
        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;
        Specified by:
        getIdBytes in interface ConstraintOrBuilder
        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:
        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;
        Specified by:
        getMessageBytes in interface ConstraintOrBuilder
        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:
        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;
        Specified by:
        getExpressionBytes in interface ConstraintOrBuilder
        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.