Class Context
java.lang.Object
io.aiven.commons.kafka.connector.source.task.Context
The context for a source record.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContext.Builder<T extends Context.Builder<T>>The abstract builder. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder from this contextstatic Context.Builder<?>builder(Comparable<?> primaryKey) Creates a builder for a Context.booleangetInteger(String key) Gets an optional Integer from the context.Gets an optional Long from the context.<T extends Comparable<T>>
TGet the native key as specified by this context.Gets an optional Number from the context.Gets an optional object from the context.<T> Optional<T>Gets an arbitrary object from the context.Gets the native offset for the associated data.Gets the Kafka partition as specified by the context.Gets an optional Short from the context.Gets an optional string from the context.getTopic()Gets the Kafka topic as specified by the context.inthashCode()toString()
-
Field Details
-
TOPIC_KEY
The key for the topic value. -
PARTITION_KEY
the key for the partition value. -
OFFSET_KEY
the key for the offset value. -
NATIVE_KEY
The key for the native key value.
-
-
Constructor Details
-
Context
Create a context from the properties.- Parameters:
builder- The builder to provide the properties.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
builder
Creates a builder for a Context.- Parameters:
primaryKey- the primary key.- Returns:
- a builder
-
builder
Creates a builder from this context- Returns:
- a builder for a Context.
-
getObject
Gets an arbitrary object from the context.- Type Parameters:
T- the object type to return.- Parameters:
key- the key for the object.fn- a function to convert the Object into a the desired return type.- Returns:
- an Optional containing a
Ttype or an empty optional.
-
getObject
Gets an optional object from the context.- Parameters:
key- the key to get.- Returns:
- the optional object or an empty optionl if it was not present.
-
getString
Gets an optional string from the context.- Parameters:
key- the key to get.- Returns:
- the optional string or an empty optional if it was not present.
-
getNumber
Gets an optional Number from the context.- Parameters:
key- the key to get.- Returns:
- the optional Number or an empty optional if it was not present.
-
getInteger
Gets an optional Integer from the context.- Parameters:
key- the key to get.- Returns:
- the optional Integer or an empty optional if it was not present.
-
getLong
Gets an optional Long from the context.- Parameters:
key- the key to get.- Returns:
- the optional Long or an empty optional if it was not present.
-
getShort
Gets an optional Short from the context.- Parameters:
key- the key to get.- Returns:
- the optional Short or an empty optional if it was not present.
-
getTopic
Gets the Kafka topic as specified by the context.- Returns:
- an Optional kafka topic.
-
getPartition
Gets the Kafka partition as specified by the context.- Returns:
- an Optional kafka partition.
-
getNativeKey
Get the native key as specified by this context.- Type Parameters:
T- the returned native key type.- Returns:
- the Optional storage key for the native object this context is associated with.
-
getOffset
Gets the native offset for the associated data. This may be the number of bytes into the native stream that the associated data starts at, or it may be the number of lines into a text file. The offset definition is dependant upon the native data structure.- Returns:
- an optional native offset for this context.
-