@Test public void testToPairs() { List<ArrayItem> items = Arrays.asList( new ExtentItem(0, "extent1[0]"), new ExtentItem(1, "size1[1]"), new UnkownItem(2), new ExtentItem(3, "extent2[3]"), new ExtentItem(4, "size2[4]"), new ExtentItem(5, "extent3[5]") ); List<ExtentPair> expected = Arrays.asList( new ExtentPair("extent1[0]", 0, "size1[1]", 1), new ExtentPair("extent2[3]", 3, "size2[4]", 4), new ExtentPair("extent3[5]", 5, null, null) ); List<ExtentPair> result = PhysicalDescriptionMapper.toPairs(items); assertThat(result, Is.is(expected)); }
public static List<ExtentPair> toPairs(List<ArrayItem> items) { ArrayList<ExtentPair> pairs = new ArrayList<>(); List<ExtentItem> extents = MapperUtils.find(items, ExtentItem.class); for (Iterator<ExtentItem> it = extents.iterator(); it.hasNext();) { ExtentItem item = it.next(); ExtentPair pair = new ExtentPair(item.getValue(), item.getArrayIndex(), null, null); pairs.add(pair); if (it.hasNext()) { item = it.next(); pair.setSize(item.getValue()); pair.setSizeIndex(item.getArrayIndex()); } } return pairs; }
PhysicalDescriptionMapper { public static List<ExtentPair> toPairs(List<ArrayItem> items) { ArrayList<ExtentPair> pairs = new ArrayList<>(); List<ExtentItem> extents = MapperUtils.find(items, ExtentItem.class); for (Iterator<ExtentItem> it = extents.iterator(); it.hasNext();) { ExtentItem item = it.next(); ExtentPair pair = new ExtentPair(item.getValue(), item.getArrayIndex(), null, null); pairs.add(pair); if (it.hasNext()) { item = it.next(); pair.setSize(item.getValue()); pair.setSizeIndex(item.getArrayIndex()); } } return pairs; } }
PhysicalDescriptionMapper { public static List<ExtentPair> toPairs(List<ArrayItem> items) { ArrayList<ExtentPair> pairs = new ArrayList<>(); List<ExtentItem> extents = MapperUtils.find(items, ExtentItem.class); for (Iterator<ExtentItem> it = extents.iterator(); it.hasNext();) { ExtentItem item = it.next(); ExtentPair pair = new ExtentPair(item.getValue(), item.getArrayIndex(), null, null); pairs.add(pair); if (it.hasNext()) { item = it.next(); pair.setSize(item.getValue()); pair.setSizeIndex(item.getArrayIndex()); } } return pairs; }  }
PhysicalDescriptionMapper { public static List<ExtentPair> toPairs(List<ArrayItem> items) { ArrayList<ExtentPair> pairs = new ArrayList<>(); List<ExtentItem> extents = MapperUtils.find(items, ExtentItem.class); for (Iterator<ExtentItem> it = extents.iterator(); it.hasNext();) { ExtentItem item = it.next(); ExtentPair pair = new ExtentPair(item.getValue(), item.getArrayIndex(), null, null); pairs.add(pair); if (it.hasNext()) { item = it.next(); pair.setSize(item.getValue()); pair.setSizeIndex(item.getArrayIndex()); } } return pairs; }  List<ArrayItem> map(ModsDefinition mods); ModsDefinition mapPairs(ModsDefinition mods, List<ExtentPair> pairs); ModsDefinition map(ModsDefinition mods, List<ExtentPair> pairs, String preservationTreatment, String preservationStateOfArt); ModsDefinition map(ModsDefinition mods, List<ArrayItem> items); static List<ExtentPair> toPairs(List<ArrayItem> items); static List<ExtentItem> toExtents(List<ExtentPair> pairs); static String getPreservationTreatment(List<ArrayItem> items); static String getPreservationStateOfArt(List<ArrayItem> items); static List<T> filter(List<T> list, boolean include, Class<? extends ArrayItem>... types); }
PhysicalDescriptionMapper { public static List<ExtentPair> toPairs(List<ArrayItem> items) { ArrayList<ExtentPair> pairs = new ArrayList<>(); List<ExtentItem> extents = MapperUtils.find(items, ExtentItem.class); for (Iterator<ExtentItem> it = extents.iterator(); it.hasNext();) { ExtentItem item = it.next(); ExtentPair pair = new ExtentPair(item.getValue(), item.getArrayIndex(), null, null); pairs.add(pair); if (it.hasNext()) { item = it.next(); pair.setSize(item.getValue()); pair.setSizeIndex(item.getArrayIndex()); } } return pairs; }  List<ArrayItem> map(ModsDefinition mods); ModsDefinition mapPairs(ModsDefinition mods, List<ExtentPair> pairs); ModsDefinition map(ModsDefinition mods, List<ExtentPair> pairs, String preservationTreatment, String preservationStateOfArt); ModsDefinition map(ModsDefinition mods, List<ArrayItem> items); static List<ExtentPair> toPairs(List<ArrayItem> items); static List<ExtentItem> toExtents(List<ExtentPair> pairs); static String getPreservationTreatment(List<ArrayItem> items); static String getPreservationStateOfArt(List<ArrayItem> items); static List<T> filter(List<T> list, boolean include, Class<? extends ArrayItem>... types);  }