Skip to content

Commit ccf468a

Browse files
committed
Remove deprecated IteratorType (#154)
1 parent a590f9a commit ccf468a

File tree

3 files changed

+0
-120
lines changed

3 files changed

+0
-120
lines changed

src/main/java/org/lmdbjava/CursorIterable.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,23 +228,6 @@ void setV(final T val) {
228228

229229
}
230230

231-
/**
232-
* Represents the internal {@link CursorIterable} state.
233-
*
234-
* @deprecated use {@link Dbi} iterate method with a {@link KeyRange} instead
235-
*/
236-
@Deprecated
237-
public enum IteratorType {
238-
/**
239-
* Move forward.
240-
*/
241-
FORWARD,
242-
/**
243-
* Move backward.
244-
*/
245-
BACKWARD
246-
}
247-
248231
/**
249232
* Represents the internal {@link CursorIterator} state.
250233
*/

src/main/java/org/lmdbjava/Dbi.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,10 @@
3030
import jnr.ffi.Pointer;
3131
import jnr.ffi.byref.IntByReference;
3232
import jnr.ffi.byref.PointerByReference;
33-
import org.lmdbjava.CursorIterable.IteratorType;
34-
import static org.lmdbjava.CursorIterable.IteratorType.FORWARD;
3533
import static org.lmdbjava.Dbi.KeyExistsException.MDB_KEYEXIST;
3634
import static org.lmdbjava.Dbi.KeyNotFoundException.MDB_NOTFOUND;
3735
import static org.lmdbjava.Env.SHOULD_CHECK;
3836
import static org.lmdbjava.KeyRange.all;
39-
import static org.lmdbjava.KeyRange.allBackward;
40-
import static org.lmdbjava.KeyRange.atLeast;
41-
import static org.lmdbjava.KeyRange.atLeastBackward;
4237
import org.lmdbjava.Library.ComparatorCallback;
4338
import static org.lmdbjava.Library.LIB;
4439
import org.lmdbjava.Library.MDB_stat;
@@ -55,7 +50,6 @@
5550
*
5651
* @param <T> buffer type
5752
*/
58-
@SuppressWarnings("PMD.GodClass")
5953
public final class Dbi<T> {
6054

6155
private final ComparatorCallback ccb;
@@ -263,50 +257,6 @@ public CursorIterable<T> iterate(final Txn<T> txn) {
263257
return iterate(txn, all());
264258
}
265259

266-
/**
267-
* Iterate the database from the first/last item and forwards/backwards.
268-
*
269-
* @param txn transaction handle (not null; not committed)
270-
* @param type direction of iterator (not null)
271-
* @return iterator (never null)
272-
* @deprecated use iterate method with a {@link KeyRange} instead
273-
*/
274-
@Deprecated
275-
public CursorIterable<T> iterate(final Txn<T> txn, final IteratorType type) {
276-
if (SHOULD_CHECK) {
277-
requireNonNull(type);
278-
}
279-
final KeyRange<T> range = type == FORWARD ? all() : allBackward();
280-
return iterate(txn, range);
281-
}
282-
283-
/**
284-
* Iterate the database from the first/last item and forwards/backwards by
285-
* first seeking to the provided key.
286-
*
287-
* @param txn transaction handle (not null; not committed)
288-
* @param key the key to search from (may be null to denote first record)
289-
* @param type direction of iterator (not null)
290-
* @return iterator (never null)
291-
* @deprecated use iterate method with a {@link KeyRange} instead
292-
*/
293-
@Deprecated
294-
public CursorIterable<T> iterate(final Txn<T> txn, final T key,
295-
final IteratorType type) {
296-
if (SHOULD_CHECK) {
297-
requireNonNull(type);
298-
}
299-
300-
final KeyRange<T> range;
301-
if (type == FORWARD) {
302-
range = key == null ? all() : atLeast(key);
303-
} else {
304-
range = key == null ? allBackward() : atLeastBackward(key);
305-
}
306-
307-
return iterate(txn, range);
308-
}
309-
310260
/**
311261
* Iterate the database in accordance with the provided {@link KeyRange} and
312262
* default {@link Comparator}.

src/test/java/org/lmdbjava/CursorIteratorTest.java

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
import org.junit.Rule;
4242
import org.junit.Test;
4343
import org.junit.rules.TemporaryFolder;
44-
import static org.lmdbjava.CursorIterable.IteratorType.BACKWARD;
45-
import static org.lmdbjava.CursorIterable.IteratorType.FORWARD;
4644
import org.lmdbjava.CursorIterable.KeyVal;
4745
import static org.lmdbjava.DbiFlags.MDB_CREATE;
4846
import static org.lmdbjava.Env.create;
@@ -121,31 +119,6 @@ public void atMostTest() {
121119
verify(atMost(bb(6)), 2, 4, 6);
122120
}
123121

124-
@Test
125-
public void backwardDeprecated() {
126-
try (Txn<ByteBuffer> txn = env.txnRead();
127-
CursorIterable<ByteBuffer> c = db.iterate(txn, BACKWARD)) {
128-
for (final KeyVal<ByteBuffer> kv : c) {
129-
assertThat(kv.val().getInt(), is(list.pollLast()));
130-
assertThat(kv.key().getInt(), is(list.pollLast()));
131-
}
132-
}
133-
}
134-
135-
@Test
136-
public void backwardSeekDeprecated() {
137-
final ByteBuffer key = bb(6);
138-
list.pollLast();
139-
list.pollLast();
140-
try (Txn<ByteBuffer> txn = env.txnRead();
141-
CursorIterable<ByteBuffer> c = db.iterate(txn, key, BACKWARD)) {
142-
for (final KeyVal<ByteBuffer> kv : c) {
143-
assertThat(kv.val().getInt(), is(list.pollLast()));
144-
assertThat(kv.key().getInt(), is(list.pollLast()));
145-
}
146-
}
147-
}
148-
149122
@Before
150123
@SuppressWarnings("PMD.CloseResource")
151124
public void before() throws IOException {
@@ -195,32 +168,6 @@ public void closedTest() {
195168
verify(closed(bb(1), bb(7)), 2, 4, 6);
196169
}
197170

198-
@Test
199-
public void forwardDeprecated() {
200-
try (Txn<ByteBuffer> txn = env.txnRead();
201-
CursorIterable<ByteBuffer> c = db.iterate(txn, FORWARD)) {
202-
for (final KeyVal<ByteBuffer> kv : c) {
203-
assertThat(kv.key().getInt(), is(list.pollFirst()));
204-
assertThat(kv.val().getInt(), is(list.pollFirst()));
205-
}
206-
}
207-
}
208-
209-
@Test
210-
public void forwardSeekDeprecated() {
211-
final ByteBuffer key = bb(4);
212-
list.pollFirst();
213-
list.pollFirst();
214-
215-
try (Txn<ByteBuffer> txn = env.txnRead();
216-
CursorIterable<ByteBuffer> c = db.iterate(txn, key, FORWARD)) {
217-
for (final KeyVal<ByteBuffer> kv : c) {
218-
assertThat(kv.key().getInt(), is(list.pollFirst()));
219-
assertThat(kv.val().getInt(), is(list.pollFirst()));
220-
}
221-
}
222-
}
223-
224171
@Test
225172
public void greaterThanBackwardTest() {
226173
verify(greaterThanBackward(bb(6)), 4, 2);

0 commit comments

Comments
 (0)