@Test void iterator() { Iterator<Entity> it = excelSheetReader.iterator(); assertTrue(it.hasNext()); Entity row1 = it.next(); assertEquals("val1", row1.get("col1")); assertEquals("val2", row1.get("col2")); assertTrue(it.hasNext()); Entity row2 = it.next(); assertEquals("val3", row2.get("col1")); assertEquals("val4", row2.get("col2")); assertTrue(it.hasNext()); Entity row3 = it.next(); assertEquals("XXX", row3.get("col1")); assertEquals("val6", row3.get("col2")); assertTrue(it.hasNext()); Entity row4 = it.next(); assertEquals("1.2", row4.get("col1")); assertEquals("2.4", row4.get("col2")); assertFalse(it.hasNext()); }
@Override public Iterator<Entity> iterator() { final Iterator<Row> it = sheet.iterator(); if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); Row headerRow = it.next(); if (colNamesMap == null) { colNamesMap = toColNamesMap(headerRow); } if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); return new Iterator<Entity>() { ExcelEntity next = null; @Override public boolean hasNext() { getAndUpdateNext(); return next != null; } @Override public ExcelEntity next() { boolean hasNext = hasNext(); if (!hasNext) { throw new NoSuchElementException(); } ExcelEntity result = next; next = null; return result; } @Override public void remove() { throw new UnsupportedOperationException(); } private void getAndUpdateNext() { if (it.hasNext() && next == null) { ExcelEntity entity = new ExcelEntity(it.next(), colNamesMap, cellProcessors, getEntityType()); for (String name : entity.getAttributeNames()) { if (StringUtils.isNotEmpty(entity.getString(name))) { next = entity; break; } } if (next == null) { getAndUpdateNext(); } } } }; }
ExcelRepository extends AbstractRepository { @Override public Iterator<Entity> iterator() { final Iterator<Row> it = sheet.iterator(); if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); Row headerRow = it.next(); if (colNamesMap == null) { colNamesMap = toColNamesMap(headerRow); } if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); return new Iterator<Entity>() { ExcelEntity next = null; @Override public boolean hasNext() { getAndUpdateNext(); return next != null; } @Override public ExcelEntity next() { boolean hasNext = hasNext(); if (!hasNext) { throw new NoSuchElementException(); } ExcelEntity result = next; next = null; return result; } @Override public void remove() { throw new UnsupportedOperationException(); } private void getAndUpdateNext() { if (it.hasNext() && next == null) { ExcelEntity entity = new ExcelEntity(it.next(), colNamesMap, cellProcessors, getEntityType()); for (String name : entity.getAttributeNames()) { if (StringUtils.isNotEmpty(entity.getString(name))) { next = entity; break; } } if (next == null) { getAndUpdateNext(); } } } }; } }
ExcelRepository extends AbstractRepository { @Override public Iterator<Entity> iterator() { final Iterator<Row> it = sheet.iterator(); if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); Row headerRow = it.next(); if (colNamesMap == null) { colNamesMap = toColNamesMap(headerRow); } if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); return new Iterator<Entity>() { ExcelEntity next = null; @Override public boolean hasNext() { getAndUpdateNext(); return next != null; } @Override public ExcelEntity next() { boolean hasNext = hasNext(); if (!hasNext) { throw new NoSuchElementException(); } ExcelEntity result = next; next = null; return result; } @Override public void remove() { throw new UnsupportedOperationException(); } private void getAndUpdateNext() { if (it.hasNext() && next == null) { ExcelEntity entity = new ExcelEntity(it.next(), colNamesMap, cellProcessors, getEntityType()); for (String name : entity.getAttributeNames()) { if (StringUtils.isNotEmpty(entity.getString(name))) { next = entity; break; } } if (next == null) { getAndUpdateNext(); } } } }; } ExcelRepository(
      Sheet sheet, EntityTypeFactory entityTypeFactory, AttributeFactory attrMetaFactory);  ExcelRepository(
      Sheet sheet,
      EntityTypeFactory entityTypeFactory,
      AttributeFactory attrMetaFactory,
      List<CellProcessor> cellProcessors); }
ExcelRepository extends AbstractRepository { @Override public Iterator<Entity> iterator() { final Iterator<Row> it = sheet.iterator(); if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); Row headerRow = it.next(); if (colNamesMap == null) { colNamesMap = toColNamesMap(headerRow); } if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); return new Iterator<Entity>() { ExcelEntity next = null; @Override public boolean hasNext() { getAndUpdateNext(); return next != null; } @Override public ExcelEntity next() { boolean hasNext = hasNext(); if (!hasNext) { throw new NoSuchElementException(); } ExcelEntity result = next; next = null; return result; } @Override public void remove() { throw new UnsupportedOperationException(); } private void getAndUpdateNext() { if (it.hasNext() && next == null) { ExcelEntity entity = new ExcelEntity(it.next(), colNamesMap, cellProcessors, getEntityType()); for (String name : entity.getAttributeNames()) { if (StringUtils.isNotEmpty(entity.getString(name))) { next = entity; break; } } if (next == null) { getAndUpdateNext(); } } } }; } ExcelRepository(
      Sheet sheet, EntityTypeFactory entityTypeFactory, AttributeFactory attrMetaFactory);  ExcelRepository(
      Sheet sheet,
      EntityTypeFactory entityTypeFactory,
      AttributeFactory attrMetaFactory,
      List<CellProcessor> cellProcessors); int getNrRows(); @Override Iterator<Entity> iterator(); void addCellProcessor(CellProcessor cellProcessor); EntityType getEntityType(); @Override Set<RepositoryCapability> getCapabilities(); @Override long count(); }
ExcelRepository extends AbstractRepository { @Override public Iterator<Entity> iterator() { final Iterator<Row> it = sheet.iterator(); if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); Row headerRow = it.next(); if (colNamesMap == null) { colNamesMap = toColNamesMap(headerRow); } if (!it.hasNext()) return Collections.<Entity>emptyList().iterator(); return new Iterator<Entity>() { ExcelEntity next = null; @Override public boolean hasNext() { getAndUpdateNext(); return next != null; } @Override public ExcelEntity next() { boolean hasNext = hasNext(); if (!hasNext) { throw new NoSuchElementException(); } ExcelEntity result = next; next = null; return result; } @Override public void remove() { throw new UnsupportedOperationException(); } private void getAndUpdateNext() { if (it.hasNext() && next == null) { ExcelEntity entity = new ExcelEntity(it.next(), colNamesMap, cellProcessors, getEntityType()); for (String name : entity.getAttributeNames()) { if (StringUtils.isNotEmpty(entity.getString(name))) { next = entity; break; } } if (next == null) { getAndUpdateNext(); } } } }; } ExcelRepository(
      Sheet sheet, EntityTypeFactory entityTypeFactory, AttributeFactory attrMetaFactory);  ExcelRepository(
      Sheet sheet,
      EntityTypeFactory entityTypeFactory,
      AttributeFactory attrMetaFactory,
      List<CellProcessor> cellProcessors); int getNrRows(); @Override Iterator<Entity> iterator(); void addCellProcessor(CellProcessor cellProcessor); EntityType getEntityType(); @Override Set<RepositoryCapability> getCapabilities(); @Override long count();  }