Skip to content

How about some Builders in lambda-java-events #566

@charlie-harvey-beable

Description

@charlie-harvey-beable

The core AWS Java/Kotlin libraries provide builders for just about every object. Builders abound! In the aws-lambda-java-events library we get sad old POJOs.

val messageAttribute = SQSEvent.MessageAttribute()
messageAttribute.stringValue = "So Verbose!"

val sqsMessage = SQSEvent.SQSMessage()
sqsMessage.body = objectMapper.writeValueAsString(DummyMessage(name = "Bob"))
sqsMessage.messageAttributes["So-Much-Typing"] = messageAttribute  // <<-- whoops, error, messageAttributes is null

I guess I could do this, but its not winning any awards:

val messageAttribute = SQSEvent.MessageAttribute()
messageAttribute.stringValue = "Still have to do this on two lines"

val sqsMessage = SQSEvent.SQSMessage()
sqsMessage.body = objectMapper.writeValueAsString(DummyMessage(name = "Bob"))
sqsMessage.messageAttributes = mapOf("So-Much-Typing" to messageAttribute)

I'm using SQSEvent as an example because that's what I was working with today. But same goes for SNSEvent, S3Event, ScheduleEvent, LexEvent...

I see that KafkaEvent uses Lombok. I'd take that.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions