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

nats-io / nats.java / #1925

20 Mar 2025 03:46PM UTC coverage: 95.662% (-0.3%) from 95.95%
#1925

push

github

web-flow
Merge pull request #1239 from nats-io/main-2-11

Main for server v2.11

179 of 219 new or added lines in 15 files covered. (81.74%)

2 existing lines in 2 files now uncovered.

11600 of 12126 relevant lines covered (95.66%)

0.96 hits per line

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

50.0
/src/main/java/io/nats/client/api/MessageDeleteRequest.java
1
// Copyright 2022 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

14
package io.nats.client.api;
15

16
import io.nats.client.support.JsonSerializable;
17

18
import static io.nats.client.support.ApiConstants.NO_ERASE;
19
import static io.nats.client.support.ApiConstants.SEQ;
20
import static io.nats.client.support.JsonUtils.*;
21

22
/**
23
 * Object used to make a request for message delete requests.
24
 */
25
public class MessageDeleteRequest implements JsonSerializable {
26
    private final long sequence;
27
    private final boolean erase;
28

29
    public MessageDeleteRequest(long sequence, boolean erase) {
1✔
30
        this.sequence = sequence;
1✔
31
        this.erase = erase;
1✔
32
    }
1✔
33

34
    public long getSequence() {
35
        return sequence;
1✔
36
    }
37

38
    public boolean isErase() {
39
        return erase;
1✔
40
    }
41

42
    public boolean isNoErase() {
43
        return !erase;
1✔
44
    }
45

46
    @Override
47
    public String toJson() {
48
        StringBuilder sb = beginJson();
1✔
49
        addField(sb, SEQ, sequence);
1✔
50
        addFldWhenTrue(sb, NO_ERASE, isNoErase());
1✔
51
        return endJson(sb).toString();
1✔
52
    }
53

54
    /**
55
     * Creates a builder for the purge options
56
     * @return a purge options builder
57
     */
58
    public static Builder builder() {
NEW
59
        return new Builder();
×
60
    }
61

NEW
62
    public static class Builder {
×
NEW
63
        private long seq = -1;
×
NEW
64
        private boolean erase = true;
×
65

66
        /**
67
         * Set upper-bound sequence for messages to be deleted
68
         * @param seq the upper-bound sequence
69
         * @return the builder
70
         */
71
        public Builder sequence(final long seq) {
NEW
72
            this.seq = seq;
×
NEW
73
            return this;
×
74
        }
75

76
        /**
77
         * set to the default, erase the message on delete
78
         * @return the builder
79
         */
80
        public Builder erase() {
NEW
81
            this.erase = true;
×
NEW
82
            return this;
×
83
        }
84

85
        /**
86
         * set to not erase the message on delete
87
         * @return the builder
88
         */
89
        public Builder noErase() {
NEW
90
            this.erase = false;
×
NEW
91
            return this;
×
92
        }
93

94
        /**
95
         * Build the MessageDeleteRequest
96
         * @return the built MessageDeleteRequest
97
         */
98
        public MessageDeleteRequest build() {
NEW
99
            return new MessageDeleteRequest(seq, erase);
×
100
        }
101
    }
102
}
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