Skip to content

Commit d4ce8ef

Browse files
committed
Add some missed contract annotations
1 parent 4dc3067 commit d4ce8ef

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/main/java/dev/siebrenvde/ntfy/message/attachment/Attachment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public sealed interface Attachment permits FileAttachment, UrlAttachment {
2020
* @return a url attachment
2121
* @see <a href="https://docs.ntfy.sh/publish/#attach-file-from-a-url">Attach file from a URL</a>
2222
*/
23+
@Contract(value = "_, _ -> new", pure = true)
2324
static UrlAttachment url(final String url, @Nullable final String fileName) {
2425
return new UrlAttachmentImpl(url, fileName);
2526
}
@@ -31,6 +32,7 @@ static UrlAttachment url(final String url, @Nullable final String fileName) {
3132
* @return a url attachment
3233
* @see <a href="https://docs.ntfy.sh/publish/#attach-file-from-a-url">Attach file from a URL</a>
3334
*/
35+
@Contract(value = "_ -> new", pure = true)
3436
static UrlAttachment url(final String url) {
3537
return new UrlAttachmentImpl(url, null);
3638
}
@@ -43,6 +45,7 @@ static UrlAttachment url(final String url) {
4345
* @return a file attachment
4446
* @see <a href="https://docs.ntfy.sh/publish/#attach-local-file">Attach local file</a>
4547
*/
48+
@Contract(value = "_, _ -> new", pure = true)
4649
static FileAttachment file(final Path file, @Nullable final String fileName) {
4750
return new FileAttachmentImpl(file, fileName);
4851
}
@@ -54,6 +57,7 @@ static FileAttachment file(final Path file, @Nullable final String fileName) {
5457
* @return a file attachment
5558
* @see <a href="https://docs.ntfy.sh/publish/#attach-local-file">Attach local file</a>
5659
*/
60+
@Contract(value = "_ -> new", pure = true)
5761
static FileAttachment file(final Path file) {
5862
return new FileAttachmentImpl(file, null);
5963
}

src/main/java/dev/siebrenvde/ntfy/response/ErrorResponse.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.siebrenvde.ntfy.response;
22

33
import org.jetbrains.annotations.ApiStatus;
4+
import org.jetbrains.annotations.Contract;
45
import org.jspecify.annotations.Nullable;
56

67
/**
@@ -11,21 +12,25 @@ public sealed interface ErrorResponse permits ErrorResponseImpl {
1112
/**
1213
* {@return the ntfy error code}
1314
*/
15+
@Contract(pure = true)
1416
int code();
1517

1618
/**
1719
* {@return the HTTP error code}
1820
*/
21+
@Contract(pure = true)
1922
int http();
2023

2124
/**
2225
* {@return a description of the error}
2326
*/
27+
@Contract(pure = true)
2428
String error();
2529

2630
/**
2731
* {@return a link to the documentation that may explain the issue}
2832
*/
33+
@Contract(pure = true)
2934
@Nullable String link();
3035

3136
@ApiStatus.Internal

src/main/java/dev/siebrenvde/ntfy/response/PublishResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.siebrenvde.ntfy.response;
22

33
import org.jetbrains.annotations.ApiStatus;
4+
import org.jetbrains.annotations.Contract;
45
import org.jspecify.annotations.Nullable;
56

67
import java.time.Instant;
@@ -13,16 +14,19 @@ public sealed interface PublishResponse permits PublishResponseImpl {
1314
/**
1415
* {@return the message id}
1516
*/
17+
@Contract(pure = true)
1618
String id();
1719

1820
/**
1921
* {@return the time at which the message was or will be published}
2022
*/
23+
@Contract(pure = true)
2124
Instant time();
2225

2326
/**
2427
* {@return the time at which the message will be deleted, or <code>null</code> if caching is disabled}
2528
*/
29+
@Contract(pure = true)
2630
@Nullable Instant expires();
2731

2832
@ApiStatus.Internal

0 commit comments

Comments
 (0)