Skip to content

Comments

Add @Required annotation with optional validator#1558

Open
fst-john wants to merge 7 commits intoslackapi:mainfrom
fst-john:fstj_add_required_annotation
Open

Add @Required annotation with optional validator#1558
fst-john wants to merge 7 commits intoslackapi:mainfrom
fst-john:fstj_add_required_annotation

Conversation

@fst-john
Copy link

@fst-john fst-john commented Feb 24, 2026

Adds a new @Required annotation to the model package for use in marking attributes in model classes as "required". This is so we can annotate attributes of our model classes that are expected to be present on every instance of the object, so developers can safely access without any explicit null checks. Meant to be a drop-in replacement for in-line code comments or javadocs that state the same (but apply no actual enforcement at runtime)

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.

@fst-john fst-john requested a review from a team as a code owner February 24, 2026 20:34
@vegeris
Copy link
Contributor

vegeris commented Feb 24, 2026

Looks like this has been a requested feature for GSON for some time now

@fst-john
Copy link
Author

Looks like this has been a requested feature for GSON for some time now

Oh yeah nice! Really the only thing I added in this implementation was to allow folks to define their own predicate that should be applied against the field that the annotation was added on. This was mainly so that folks could handle primitive types (if they wanted) since these get boxed automatically by the JVM. We could make it "dumber" though and do something similar to the stack overflow link where primitives are checked against their JVM defaults, that kinda thing 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants