Skip to content

Annotating API objects with NotNull and Nullable #1333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Annotating Stream and Consumer Configuration
  • Loading branch information
scottf committed Jun 18, 2025
commit 82c6341ec9bb65f243e9e9fdca11d74228898e7a
23 changes: 22 additions & 1 deletion src/main/java/io/nats/client/api/ConsumerConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.nats.client.PushSubscribeOptions;
import io.nats.client.support.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.time.Duration;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -221,6 +222,7 @@ else if (filterSubjects.size() == 1) {
* Gets the name of the description of this consumer configuration.
* @return name of the description.
*/
@Nullable
public String getDescription() {
return description;
}
Expand All @@ -229,6 +231,7 @@ public String getDescription() {
* Gets the name of the durable name for this consumer configuration.
* @return name of the durable.
*/
@Nullable
public String getDurable() {
return durable;
}
Expand All @@ -237,6 +240,7 @@ public String getDurable() {
* Gets the name of the consumer name for this consumer configuration.
* @return name of the consumer.
*/
@Nullable
public String getName() {
return name;
}
Expand All @@ -245,6 +249,7 @@ public String getName() {
* Gets the deliver subject of this consumer configuration.
* @return the deliver subject.
*/
@Nullable
public String getDeliverSubject() {
return deliverSubject;
}
Expand All @@ -253,6 +258,7 @@ public String getDeliverSubject() {
* Gets the deliver group of this consumer configuration.
* @return the deliver group.
*/
@Nullable
public String getDeliverGroup() {
return deliverGroup;
}
Expand All @@ -261,6 +267,7 @@ public String getDeliverGroup() {
* Gets the deliver policy of this consumer configuration.
* @return the deliver policy.
*/
@NotNull
public DeliverPolicy getDeliverPolicy() {
return GetOrDefault(deliverPolicy);
}
Expand All @@ -277,6 +284,7 @@ public long getStartSequence() {
* Gets the start time of this consumer configuration.
* @return the start time.
*/
@Nullable
public ZonedDateTime getStartTime() {
return startTime;
}
Expand All @@ -285,6 +293,7 @@ public ZonedDateTime getStartTime() {
* Gets the acknowledgment policy of this consumer configuration.
* @return the acknowledgment policy.
*/
@NotNull
public AckPolicy getAckPolicy() {
return GetOrDefault(ackPolicy);
}
Expand All @@ -293,6 +302,7 @@ public AckPolicy getAckPolicy() {
* Gets the acknowledgment wait of this consumer configuration.
* @return the acknowledgment wait duration.
*/
@Nullable
public Duration getAckWait() {
return ackWait;
}
Expand All @@ -311,6 +321,7 @@ public long getMaxDeliver() {
* return null if there are not exactly one filter subjects
* @return the first filter subject.
*/
@Nullable
public String getFilterSubject() {
return filterSubjects == null || filterSubjects.size() != 1 ? null : filterSubjects.get(0);
}
Expand All @@ -319,6 +330,7 @@ public String getFilterSubject() {
* Gets the filter subjects as a list. May be null, otherwise won't be empty
* @return the list
*/
@Nullable
public List<String> getFilterSubjects() {
return filterSubjects;
}
Expand All @@ -327,6 +339,7 @@ public List<String> getFilterSubjects() {
* Gets the priority groups as a list. May be null, otherwise won't be empty
* @return the list
*/
@Nullable
public List<String> getPriorityGroups() {
return priorityGroups;
}
Expand All @@ -343,6 +356,7 @@ public boolean hasMultipleFilterSubjects() {
* Gets the replay policy of this consumer configuration.
* @return the replay policy.
*/
@NotNull
public ReplayPolicy getReplayPolicy() {
return GetOrDefault(replayPolicy);
}
Expand All @@ -367,15 +381,16 @@ public long getMaxAckPending() {
* Gets the sample frequency.
* @return sampleFrequency.
*/
@Nullable
public String getSampleFrequency() {
return sampleFrequency;
}


/**
* Gets the idle heart beat wait time
* @return the idle heart beat wait duration.
*/
@Nullable
public Duration getIdleHeartbeat() {
return idleHeartbeat;
}
Expand Down Expand Up @@ -434,6 +449,7 @@ public long getMaxBytes() {
* Get the max amount of expire time for the server to allow on pull requests.
* @return the max expire
*/
@Nullable
public Duration getMaxExpires() {
return maxExpires;
}
Expand All @@ -442,6 +458,7 @@ public Duration getMaxExpires() {
* Get the amount of time before the consumer is deemed inactive.
* @return the inactive threshold
*/
@Nullable
public Duration getInactiveThreshold() {
return inactiveThreshold;
}
Expand All @@ -450,6 +467,7 @@ public Duration getInactiveThreshold() {
* Get the backoff list; may be empty, will never be null.
* @return the list
*/
@NotNull
public List<Duration> getBackoff() {
return backoff == null ? Collections.emptyList() : backoff;
}
Expand All @@ -458,6 +476,7 @@ public List<Duration> getBackoff() {
* Metadata for the consumer; may be empty, will never be null.
* @return the metadata map
*/
@NotNull
public Map<String, String> getMetadata() {
return metadata == null ? Collections.emptyMap() : metadata;
}
Expand All @@ -472,6 +491,7 @@ public Map<String, String> getMetadata() {
* Get the time until the consumer is paused.
* @return paused until time
*/
@Nullable
public ZonedDateTime getPauseUntil() {
return pauseUntil;
}
Expand All @@ -480,6 +500,7 @@ public ZonedDateTime getPauseUntil() {
* Gets the priority policy of this consumer configuration.
* @return the priority policy.
*/
@NotNull
public PriorityPolicy getPriorityPolicy() {
return GetOrDefault(priorityPolicy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public OrderedConsumerConfiguration(@NotNull JsonValue v) throws JsonParseExcept
@NotNull
public String toJson() {
StringBuilder sb = beginJson();
JsonUtils.addStrings(sb, FILTER_SUBJECTS, filterSubjects); // filter will always have at lease a GREATER_THAN
JsonUtils.addStrings(sb, FILTER_SUBJECTS, filterSubjects); // filter will always have at least a GREATER_THAN
if (deliverPolicy != null) {
JsonUtils.addField(sb, DELIVER_POLICY, deliverPolicy.toString());
}
Expand Down
25 changes: 22 additions & 3 deletions src/main/java/io/nats/client/api/StreamConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import io.nats.client.support.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.time.Duration;
import java.util.*;
Expand Down Expand Up @@ -215,6 +216,7 @@ public String toJson() {
* Gets the name of this stream configuration.
* @return the name of the stream.
*/
@NotNull
public String getName() {
return name;
}
Expand All @@ -223,6 +225,7 @@ public String getName() {
* Gets the description of this stream configuration.
* @return the description of the stream.
*/
@Nullable
public String getDescription() {
return description;
}
Expand All @@ -231,6 +234,7 @@ public String getDescription() {
* Gets the subjects for this stream configuration.
* @return the subject of the stream.
*/
@NotNull
public List<String> getSubjects() {
return subjects;
}
Expand All @@ -239,6 +243,7 @@ public List<String> getSubjects() {
* Gets the discard policy for this stream configuration.
* @return the discard policy of the stream.
*/
@Nullable
public DiscardPolicy getDiscardPolicy() {
return discardPolicy;
}
Expand All @@ -247,6 +252,7 @@ public DiscardPolicy getDiscardPolicy() {
* Gets the retention policy for this stream configuration.
* @return the retention policy for this stream.
*/
@NotNull
public RetentionPolicy getRetentionPolicy() {
return retentionPolicy;
}
Expand All @@ -255,6 +261,7 @@ public RetentionPolicy getRetentionPolicy() {
* Gets the compression option for this stream configuration.
* @return the compression option for this stream.
*/
@Nullable
public CompressionOption getCompressionOption() {
return compressionOption;
}
Expand Down Expand Up @@ -294,7 +301,8 @@ public long getMaxBytes() {
/**
* Gets the maximum message age for this stream configuration.
* @return the maximum message age for this stream.
*/
*/
@NotNull
public Duration getMaxAge() {
return maxAge;
}
Expand All @@ -321,6 +329,7 @@ public int getMaximumMessageSize() {
* Gets the storage type for this stream configuration.
* @return the storage type for this stream.
*/
@NotNull
public StorageType getStorageType() {
return storageType;
}
Expand All @@ -344,7 +353,8 @@ public boolean getNoAck() {
/**
* Gets the template json for this stream configuration.
* @return the template for this stream.
*/
*/
@Nullable
public String getTemplateOwner() {
return templateOwner;
}
Expand All @@ -353,7 +363,8 @@ public String getTemplateOwner() {
* Gets the duplicate checking window stream configuration. Duration.ZERO
* means duplicate checking is not enabled.
* @return the duration of the window.
*/
*/
@Nullable
public Duration getDuplicateWindow() {
return duplicateWindow;
}
Expand All @@ -363,6 +374,7 @@ public Duration getDuplicateWindow() {
* random placement when unset. May be null.
* @return the placement object
*/
@Nullable
public Placement getPlacement() {
return placement;
}
Expand All @@ -371,6 +383,7 @@ public Placement getPlacement() {
* Get the republish configuration. May be null.
* @return the republish object
*/
@Nullable
public Republish getRepublish() {
return republish;
}
Expand All @@ -379,6 +392,7 @@ public Republish getRepublish() {
* Get the subjectTransform configuration. May be null.
* @return the subjectTransform object
*/
@Nullable
public SubjectTransform getSubjectTransform() {
return subjectTransform;
}
Expand All @@ -387,6 +401,7 @@ public SubjectTransform getSubjectTransform() {
* Get the consumerLimits configuration. May be null.
* @return the consumerLimits object
*/
@Nullable
public ConsumerLimits getConsumerLimits() {
return consumerLimits;
}
Expand All @@ -395,6 +410,7 @@ public ConsumerLimits getConsumerLimits() {
* The mirror definition for this stream
* @return the mirror
*/
@Nullable
public Mirror getMirror() {
return mirror;
}
Expand All @@ -403,6 +419,7 @@ public Mirror getMirror() {
* The sources for this stream
* @return the sources
*/
@Nullable
public List<Source> getSources() {
return sources;
}
Expand Down Expand Up @@ -468,6 +485,7 @@ public boolean isDiscardNewPerSubject() {
* Metadata for the stream
* @return the metadata map. Might be null.
*/
@Nullable
public Map<String, String> getMetadata() {
return metadata;
}
Expand All @@ -492,6 +510,7 @@ public boolean isAllowMessageTtl() {
* Get the Subject Delete Marker TTL duration. May be null.
* @return The duration
*/
@Nullable
public Duration getSubjectDeleteMarkerTtl() {
return subjectDeleteMarkerTtl;
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy