From a24c1042499f76ff2d442ae133ef165011a7af4c Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Mon, 12 Jul 2021 15:53:22 -0300 Subject: Formatting tweaks --- .../java/bjc/utils/ioutils/blocks/BlockReader.java | 58 ++++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java') diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java index f111244..0968050 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java @@ -1,58 +1,50 @@ package bjc.utils.ioutils.blocks; -import java.io.IOException; -import java.util.Iterator; -import java.util.function.Consumer; +import java.io.*; +import java.util.*; +import java.util.function.*; -/** - * A source of blocks of characters, marked with line numbers as to block +// @NOTE Ben Culkin 12/16/2020 :IterableIterator +// Having this class implement both Iterator and Iterable is somewhat suspect. +// I understand why it was done, because that allows easy use of the 'for-each' +// loop semantics, but there is a question of whether it is a good idea to have +// instances of Iterable that will always give the same Iterator without +// explicitly saying that is what they are doing. + +/** A source of blocks of characters, marked with line numbers as to block * start/block end. * - * @author bjculkin - * - */ -public interface BlockReader extends AutoCloseable, Iterator, Iterable { - /** - * Check if this reader has an available block. + * @author bjculkin */ +public interface +BlockReader extends AutoCloseable, Iterator, Iterable { + /** Check if this reader has an available block. * - * @return Whether or not another block is available. - */ + * @return Whether or not another block is available. */ boolean hasNextBlock(); - /** - * Get the current block. + /** Get the current block. * - * @return The current block, or null if there is no current block. - */ + * @return The current block, or null if there is no current block. */ Block getBlock(); - /** - * Move to the next block. + /** Move to the next block. * - * @return Whether or not the next block was successfully read. - */ + * @return Whether or not the next block was successfully read. */ boolean nextBlock(); - /** - * Retrieve the number of blocks that have been read so far. + /** Retrieve the number of blocks that have been read so far. * - * @return The number of blocks read so far. - */ + * @return The number of blocks read so far. */ int getBlockCount(); @Override void close() throws IOException; - /* - * Methods with default impls. - */ + /* Methods with default impls. */ - /** - * Execute an action for each remaining block. + /** Execute an action for each remaining block. * - * @param action - * The action to execute for each block - */ + * @param action The action to execute for each block. */ default void forEachBlock(final Consumer action) { while (hasNext()) { action.accept(next()); -- cgit v1.2.3