@Override public String nextLine() { Key key = null; if (effectiveDateToFilterFor == null) { if (iterator.hasNext()) { key = iterator.next(); } } else { while (key == null && iterator.hasNext()) { Key unfilteredKey = iterator.next(); if (effectiveDateToFilterFor.equals(unfilteredKey.getDate())) { key = unfilteredKey; } } } if (key != null) { return formatLine(key); } else { return null; } }
private String formatLine(Key key) { return String.format(FORMAT, key.getIdString(), key.getDate(), table.get(key)); }