mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Use predicates to specify records to accept or ignore.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package org.briarproject.bramble.api;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface Predicate<T> {
|
||||
|
||||
boolean test(T t);
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package org.briarproject.bramble.api.record;
|
||||
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.Predicate;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface RecordReader {
|
||||
|
||||
@@ -16,5 +20,20 @@ public interface RecordReader {
|
||||
*/
|
||||
Record readRecord() throws IOException;
|
||||
|
||||
/**
|
||||
* Reads and returns the next record matching the 'accept' predicate,
|
||||
* skipping any records that match the 'ignore' predicate. Returns null if
|
||||
* no record matching the 'accept' predicate is found before the end of the
|
||||
* stream.
|
||||
*
|
||||
* @throws EOFException If the end of the stream is reached without
|
||||
* reading a complete record
|
||||
* @throws FormatException If a record is read that does not match the
|
||||
* 'accept' or 'ignore' predicates
|
||||
*/
|
||||
@Nullable
|
||||
Record readRecord(Predicate<Record> accept, Predicate<Record> ignore)
|
||||
throws IOException;
|
||||
|
||||
void close() throws IOException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user