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

nats-io / nats.java / #1986

05 Jun 2025 01:41PM UTC coverage: 95.65%. First build
#1986

push

github

web-flow
Merge pull request #1323 from nats-io/kv-marker-reason

Nats-Marker-Reason must be mapped to a Key Value Operation

16 of 20 new or added lines in 2 files covered. (80.0%)

11720 of 12253 relevant lines covered (95.65%)

0.96 hits per line

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

70.59
/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
/**
16
 * Key Value Operations Enum
17
 */
18
public enum KeyValueOperation {
1✔
19
    PUT("PUT"), DELETE("DEL"), PURGE("PURGE");
1✔
20

21
    private final String headerValue;
22

23
    KeyValueOperation(String headerValue) {
1✔
24
        this.headerValue = headerValue;
1✔
25
    }
1✔
26

27
    public String getHeaderValue() {
28
        return headerValue;
1✔
29
    }
30

31
    public static KeyValueOperation instance(String s) {
32
        if (PUT.headerValue.equals(s)) return PUT;
1✔
33
        if (DELETE.headerValue.equals(s)) return DELETE;
1✔
34
        if (PURGE.headerValue.equals(s)) return PURGE;
1✔
NEW
35
        return null;
×
36
    }
37

38
    public static KeyValueOperation getOrDefault(String s, KeyValueOperation dflt) {
NEW
39
        KeyValueOperation kvo = instance(s);
×
40
        return kvo == null ? dflt : kvo;
×
41
    }
42

43
    public static KeyValueOperation instanceByMarkerReason(String markerReason) {
44
        if ("Remove".equals(markerReason)) {
1✔
NEW
45
            return DELETE;
×
46
        }
47
        if ("MaxAge".equals(markerReason) || "Purge".equals(markerReason)) {
1✔
48
            return PURGE;
1✔
49
        }
NEW
50
        return null;
×
51
    }
52
}
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