Package io.camunda.zeebe.protocol.record
Class ImmutableRecord<T extends RecordValue>
java.lang.Object
io.camunda.zeebe.protocol.record.ImmutableRecord<T>
- All Implemented Interfaces:
JsonSerializable,Record<T>
Immutable implementation of
Record.
Use the builder to create immutable instances:
ImmutableRecord.builder().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutableRecord.Builder<T extends RecordValue>Builds instances of typeImmutableRecord. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends RecordValue>
ImmutableRecord.Builder<T> builder()Creates a builder forImmutableRecord.static <T extends RecordValue>
ImmutableRecord<T> Creates an immutable copy of aRecordvalue.booleanThis instance is equal to all instances ofImmutableRecordthat have equal attribute values.Provides the authorization data of the user the triggered the creation of this record.longgetKey()Retrieves the key of the record.longThe operationReference is an id passed from clients to correlate operations with resulted recordsintlongRetrieves the position of the record.intA record version is an integer starting from 1.longReturns the position of the source record.longgetValue()Returns the raw value of the record, which should implement one of the interfaces in theio.camunda.zeebe.protocol.record.valuepackage.inthashCode()Returns a lazily computed hash code from attributes:position,sourceRecordPosition,key,timestamp,intent,partitionId,recordType,rejectionType,rejectionReason,brokerVersion,authorizations,recordVersion,valueType,value,operationReference.toString()Prints the immutable valueRecordwith attribute values.final ImmutableRecord<T> withAuthorizations(Map<String, ? extends Object> entries) Copy the current immutable object by replacing theauthorizationsmap with the specified map.final ImmutableRecord<T> withBrokerVersion(String value) Copy the current immutable object by setting a value for thebrokerVersionattribute.final ImmutableRecord<T> withIntent(Intent value) Copy the current immutable object by setting a value for theintentattribute.final ImmutableRecord<T> withKey(long value) Copy the current immutable object by setting a value for thekeyattribute.final ImmutableRecord<T> withOperationReference(long value) Copy the current immutable object by setting a value for theoperationReferenceattribute.final ImmutableRecord<T> withPartitionId(int value) Copy the current immutable object by setting a value for thepartitionIdattribute.final ImmutableRecord<T> withPosition(long value) Copy the current immutable object by setting a value for thepositionattribute.final ImmutableRecord<T> withRecordType(RecordType value) Copy the current immutable object by setting a value for therecordTypeattribute.final ImmutableRecord<T> withRecordVersion(int value) Copy the current immutable object by setting a value for therecordVersionattribute.final ImmutableRecord<T> withRejectionReason(String value) Copy the current immutable object by setting a value for therejectionReasonattribute.final ImmutableRecord<T> withRejectionType(RejectionType value) Copy the current immutable object by setting a value for therejectionTypeattribute.final ImmutableRecord<T> withSourceRecordPosition(long value) Copy the current immutable object by setting a value for thesourceRecordPositionattribute.final ImmutableRecord<T> withTimestamp(long value) Copy the current immutable object by setting a value for thetimestampattribute.final ImmutableRecord<T> Copy the current immutable object by setting a value for thevalueattribute.final ImmutableRecord<T> withValueType(ValueType value) Copy the current immutable object by setting a value for thevalueTypeattribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.camunda.zeebe.protocol.record.JsonSerializable
toJson
-
Method Details
-
getPosition
public long getPosition()Retrieves the position of the record. Positions are locally unique to the partition, and monotonically increasing. Records are then ordered on the partition by their positions, i.e. lower position means the record was published earlier.- Specified by:
getPositionin interfaceRecord<T extends RecordValue>- Returns:
- position the record
-
getSourceRecordPosition
public long getSourceRecordPosition()Returns the position of the source record. The source record denotes the record which caused the current record. It can be unset (meaning there is no source record), at which point the position returned here will be -1. Anything >= 0 implies a source record.- Specified by:
getSourceRecordPositionin interfaceRecord<T extends RecordValue>- Returns:
- position of the source record
-
getKey
public long getKey()Retrieves the key of the record.Multiple records can have the same key if they belongs to the same logical entity. Keys are unique for the combination of partition and record type.
- Specified by:
getKeyin interfaceRecord<T extends RecordValue>- Returns:
- the key of the record
-
getTimestamp
public long getTimestamp()- Specified by:
getTimestampin interfaceRecord<T extends RecordValue>- Returns:
- the unix timestamp at which the record was published on the partition.
-
getIntent
- Specified by:
getIntentin interfaceRecord<T extends RecordValue>- Returns:
- the intent of the record
-
getPartitionId
public int getPartitionId()- Specified by:
getPartitionIdin interfaceRecord<T extends RecordValue>- Returns:
- the partition ID on which the record was published
-
getRecordType
- Specified by:
getRecordTypein interfaceRecord<T extends RecordValue>- Returns:
- the type of the record (event, command or command rejection)
-
getRejectionType
- Specified by:
getRejectionTypein interfaceRecord<T extends RecordValue>- Returns:
- the type of rejection if
getRecordType()returnsRecordType.COMMAND_REJECTIONor elsenull.
-
getRejectionReason
- Specified by:
getRejectionReasonin interfaceRecord<T extends RecordValue>- Returns:
- the reason why a command was rejected if
getRecordType()returnsRecordType.COMMAND_REJECTIONor elsenull.
-
getBrokerVersion
- Specified by:
getBrokerVersionin interfaceRecord<T extends RecordValue>- Returns:
- the version of the broker that wrote this record
-
getAuthorizations
Provides the authorization data of the user the triggered the creation of this record. The following entries may be available:- Key:
authorized_tenants; Value: a List of Strings defining the user's authorized tenants.
- Specified by:
getAuthorizationsin interfaceRecord<T extends RecordValue>- Returns:
- a Map of authorization data for this record or an empty Map if not set.
- Key:
-
getRecordVersion
public int getRecordVersion()A record version is an integer starting from 1. The version of a record is defined when it is written. It allows different versions of the same record to be processed or applied differently.For example, it allows us to apply an older event in the same way as when it was originally written, while allowing newer events to be applied differently.
- Specified by:
getRecordVersionin interfaceRecord<T extends RecordValue>- Returns:
- the version of the record when written
-
getValueType
- Specified by:
getValueTypein interfaceRecord<T extends RecordValue>- Returns:
- the type of the record (e.g. job, process, process instance, etc.)
-
getValue
Returns the raw value of the record, which should implement one of the interfaces in theio.camunda.zeebe.protocol.record.valuepackage.The record value is essentially the record specific data, e.g. for a process instance creation event, it would contain information relevant to the process instance being created.
- Specified by:
getValuein interfaceRecord<T extends RecordValue>- Returns:
- record value
-
getOperationReference
public long getOperationReference()The operationReference is an id passed from clients to correlate operations with resulted records- Specified by:
getOperationReferencein interfaceRecord<T extends RecordValue>- Returns:
- the reference for the operation that produced this record
-
withPosition
Copy the current immutable object by setting a value for thepositionattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for position- Returns:
- A modified copy of the
thisobject
-
withSourceRecordPosition
Copy the current immutable object by setting a value for thesourceRecordPositionattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for sourceRecordPosition- Returns:
- A modified copy of the
thisobject
-
withKey
Copy the current immutable object by setting a value for thekeyattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for key- Returns:
- A modified copy of the
thisobject
-
withTimestamp
Copy the current immutable object by setting a value for thetimestampattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for timestamp- Returns:
- A modified copy of the
thisobject
-
withIntent
Copy the current immutable object by setting a value for theintentattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for intent (can benull)- Returns:
- A modified copy of the
thisobject
-
withPartitionId
Copy the current immutable object by setting a value for thepartitionIdattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for partitionId- Returns:
- A modified copy of the
thisobject
-
withRecordType
Copy the current immutable object by setting a value for therecordTypeattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for recordType (can benull)- Returns:
- A modified copy of the
thisobject
-
withRejectionType
Copy the current immutable object by setting a value for therejectionTypeattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for rejectionType (can benull)- Returns:
- A modified copy of the
thisobject
-
withRejectionReason
Copy the current immutable object by setting a value for therejectionReasonattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for rejectionReason (can benull)- Returns:
- A modified copy of the
thisobject
-
withBrokerVersion
Copy the current immutable object by setting a value for thebrokerVersionattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for brokerVersion (can benull)- Returns:
- A modified copy of the
thisobject
-
withAuthorizations
Copy the current immutable object by replacing theauthorizationsmap with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
entries- The entries to be added to the authorizations map- Returns:
- A modified copy of
thisobject
-
withRecordVersion
Copy the current immutable object by setting a value for therecordVersionattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for recordVersion- Returns:
- A modified copy of the
thisobject
-
withValueType
Copy the current immutable object by setting a value for thevalueTypeattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for valueType (can benull)- Returns:
- A modified copy of the
thisobject
-
withValue
Copy the current immutable object by setting a value for thevalueattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for value (can benull)- Returns:
- A modified copy of the
thisobject
-
withOperationReference
Copy the current immutable object by setting a value for theoperationReferenceattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for operationReference- Returns:
- A modified copy of the
thisobject
-
equals
This instance is equal to all instances ofImmutableRecordthat have equal attribute values. -
hashCode
public int hashCode()Returns a lazily computed hash code from attributes:position,sourceRecordPosition,key,timestamp,intent,partitionId,recordType,rejectionType,rejectionReason,brokerVersion,authorizations,recordVersion,valueType,value,operationReference. -
toString
Prints the immutable valueRecordwith attribute values. -
copyOf
Creates an immutable copy of aRecordvalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
T- generic parameter T- Parameters:
instance- The instance to copy- Returns:
- A copied immutable Record instance
-
builder
Creates a builder forImmutableRecord.ImmutableRecord.<T>builder() .withPosition(long) // optionalposition.withSourceRecordPosition(long) // optionalsourceRecordPosition.withKey(long) // optionalkey.withTimestamp(long) // optionaltimestamp.withIntent(io.camunda.zeebe.protocol.record.intent.Intent | null) // nullableintent.withPartitionId(int) // optionalpartitionId.withRecordType(io.camunda.zeebe.protocol.record.RecordType | null) // nullablerecordType.withRejectionType(io.camunda.zeebe.protocol.record.RejectionType | null) // nullablerejectionType.withRejectionReason(String | null) // nullablerejectionReason.withBrokerVersion(String | null) // nullablebrokerVersion.putAuthorization|putAllAuthorizations(String => Object) //authorizationsmappings .withRecordVersion(int) // optionalrecordVersion.withValueType(io.camunda.zeebe.protocol.record.ValueType | null) // nullablevalueType.withValue(T | null) // nullablevalue.withOperationReference(long) // optionaloperationReference.build();- Type Parameters:
T- generic parameter T- Returns:
- A new ImmutableRecord builder
-