Class ImmutableRecord.Builder<T extends RecordValue>

java.lang.Object
io.camunda.zeebe.protocol.record.ImmutableRecord.Builder<T>
Enclosing class:
ImmutableRecord<T extends RecordValue>

@NotThreadSafe public static final class ImmutableRecord.Builder<T extends RecordValue> extends Object
Builds instances of type ImmutableRecord. Initialize attributes and then invoke the build() method to create an immutable instance.

Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

  • Method Details

    • from

      public final ImmutableRecord.Builder<T> from(Record<T> instance)
      Fill a builder with attribute values from the provided Record instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • withPosition

      public final ImmutableRecord.Builder<T> withPosition(long position)
      Initializes the value for the position attribute.
      Parameters:
      position - The value for position
      Returns:
      this builder for use in a chained invocation
    • withSourceRecordPosition

      public final ImmutableRecord.Builder<T> withSourceRecordPosition(long sourceRecordPosition)
      Initializes the value for the sourceRecordPosition attribute.
      Parameters:
      sourceRecordPosition - The value for sourceRecordPosition
      Returns:
      this builder for use in a chained invocation
    • withKey

      public final ImmutableRecord.Builder<T> withKey(long key)
      Initializes the value for the key attribute.
      Parameters:
      key - The value for key
      Returns:
      this builder for use in a chained invocation
    • withTimestamp

      public final ImmutableRecord.Builder<T> withTimestamp(long timestamp)
      Initializes the value for the timestamp attribute.
      Parameters:
      timestamp - The value for timestamp
      Returns:
      this builder for use in a chained invocation
    • withIntent

      public final ImmutableRecord.Builder<T> withIntent(Intent intent)
      Initializes the value for the intent attribute.
      Parameters:
      intent - The value for intent (can be null)
      Returns:
      this builder for use in a chained invocation
    • withPartitionId

      public final ImmutableRecord.Builder<T> withPartitionId(int partitionId)
      Initializes the value for the partitionId attribute.
      Parameters:
      partitionId - The value for partitionId
      Returns:
      this builder for use in a chained invocation
    • withRecordType

      public final ImmutableRecord.Builder<T> withRecordType(RecordType recordType)
      Initializes the value for the recordType attribute.
      Parameters:
      recordType - The value for recordType (can be null)
      Returns:
      this builder for use in a chained invocation
    • withRejectionType

      public final ImmutableRecord.Builder<T> withRejectionType(RejectionType rejectionType)
      Initializes the value for the rejectionType attribute.
      Parameters:
      rejectionType - The value for rejectionType (can be null)
      Returns:
      this builder for use in a chained invocation
    • withRejectionReason

      public final ImmutableRecord.Builder<T> withRejectionReason(String rejectionReason)
      Initializes the value for the rejectionReason attribute.
      Parameters:
      rejectionReason - The value for rejectionReason (can be null)
      Returns:
      this builder for use in a chained invocation
    • withBrokerVersion

      public final ImmutableRecord.Builder<T> withBrokerVersion(String brokerVersion)
      Initializes the value for the brokerVersion attribute.
      Parameters:
      brokerVersion - The value for brokerVersion (can be null)
      Returns:
      this builder for use in a chained invocation
    • withValueType

      public final ImmutableRecord.Builder<T> withValueType(ValueType valueType)
      Initializes the value for the valueType attribute.
      Parameters:
      valueType - The value for valueType (can be null)
      Returns:
      this builder for use in a chained invocation
    • withValue

      public final ImmutableRecord.Builder<T> withValue(T value)
      Initializes the value for the value attribute.
      Parameters:
      value - The value for value (can be null)
      Returns:
      this builder for use in a chained invocation
    • clear

      public ImmutableRecord.Builder<T> clear()
      Clear the builder to the initial state.
      Returns:
      this builder for use in a chained invocation
    • build

      public ImmutableRecord<T> build()
      Builds a new ImmutableRecord.
      Returns:
      An immutable instance of Record
      Throws:
      IllegalStateException - if any required attributes are missing