• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nats-io / nats.java / #2109

15 Aug 2025 04:51PM UTC coverage: 95.404% (-0.05%) from 95.457%
#2109

push

github

web-flow
Merge pull request #1395 from nats-io/header-nullability

Header nullability

3 of 3 new or added lines in 1 file covered. (100.0%)

14 existing lines in 7 files now uncovered.

11915 of 12489 relevant lines covered (95.4%)

0.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.94
/src/main/java/io/nats/client/api/KeyValueOperation.java
1
// Copyright 2021 The NATS Authors
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at:
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13
package io.nats.client.api;
14

15
import org.jspecify.annotations.Nullable;
16

17
/**
18
 * Key Value Operations Enum
19
 */
20
public enum KeyValueOperation {
1✔
21
    PUT("PUT"), DELETE("DEL"), PURGE("PURGE");
1✔
22

23
    private final String headerValue;
24

25
    KeyValueOperation(String headerValue) {
1✔
26
        this.headerValue = headerValue;
1✔
27
    }
1✔
28

29
    public String getHeaderValue() {
30
        return headerValue;
1✔
31
    }
32

33
    @Nullable
34
    public static KeyValueOperation instance(String s) {
35
        if (PUT.headerValue.equals(s)) return PUT;
1✔
36
        if (DELETE.headerValue.equals(s)) return DELETE;
1✔
37
        if (PURGE.headerValue.equals(s)) return PURGE;
1✔
38
        return null;
×
39
    }
40

41
    @Nullable
42
    public static KeyValueOperation getOrDefault(String s, KeyValueOperation dflt) {
43
        KeyValueOperation kvo = instance(s);
×
44
        return kvo == null ? dflt : kvo;
×
45
    }
46

47
    @Nullable
48
    public static KeyValueOperation instanceByMarkerReason(String markerReason) {
UNCOV
49
        if ("Remove".equals(markerReason)) {
×
50
            return DELETE;
×
51
        }
UNCOV
52
        if ("MaxAge".equals(markerReason) || "Purge".equals(markerReason)) {
×
UNCOV
53
            return PURGE;
×
54
        }
55
        return null;
×
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc