Skip to content

Commit 98df113

Browse files
committed
Remove PutFlags.ZERO now we use varargs
1 parent 6e7a453 commit 98df113

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/main/java/org/lmdbjava/Cursor.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package org.lmdbjava;
22

33
import java.nio.ByteBuffer;
4-
import static java.util.Objects.requireNonNull;
54
import jnr.ffi.Pointer;
65
import jnr.ffi.byref.NativeLongByReference;
76
import org.lmdbjava.Library.MDB_val;
87
import static org.lmdbjava.Library.lib;
98
import static org.lmdbjava.Library.runtime;
109
import static org.lmdbjava.ValueBuffers.createVal;
1110
import static org.lmdbjava.ValueBuffers.wrap;
12-
import static org.lmdbjava.PutFlags.ZERO;
1311
import static org.lmdbjava.ResultCodeMapper.checkRc;
1412
import static java.util.Objects.requireNonNull;
13+
import static org.lmdbjava.MaskedFlag.mask;
1514

1615
public class Cursor {
1716

@@ -83,15 +82,10 @@ public void delete() throws LmdbNativeException {
8382
checkRc(lib.mdb_cursor_del(ptr, 0));
8483
}
8584

86-
public void put(ByteBuffer key, ByteBuffer val) throws LmdbNativeException {
87-
put(key, val, ZERO);
88-
}
89-
90-
public void put(ByteBuffer key, ByteBuffer val, PutFlags op)
85+
public void put(ByteBuffer key, ByteBuffer val, PutFlags... op)
9186
throws LmdbNativeException {
9287
requireNonNull(key);
9388
requireNonNull(val);
94-
requireNonNull(op);
9589
if (tx.isCommitted()) {
9690
throw new IllegalArgumentException("transaction already committed");
9791
}
@@ -100,7 +94,8 @@ public void put(ByteBuffer key, ByteBuffer val, PutFlags op)
10094
}
10195
final MDB_val k = createVal(key);
10296
final MDB_val v = createVal(val);
103-
checkRc(lib.mdb_cursor_put(ptr, k, v, op.getMask()));
97+
final int flags = mask(op);
98+
checkRc(lib.mdb_cursor_put(ptr, k, v, flags));
10499
}
105100

106101
public void renew(Transaction tx) throws LmdbNativeException {

src/main/java/org/lmdbjava/PutFlags.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
public enum PutFlags implements MaskedFlag {
77

8-
ZERO(0x0),
98
/**
109
* For put: Don't write if the key already exists.
1110
*/

0 commit comments

Comments
 (0)