@Test public void testRead() { String xml = "<mods xmlns='http: + "<physicalDescription>" + "<extent>extent1[0]</extent>" + "<extent>size1[1]</extent>" + "<note/>" + "<extent>extent2[3]</extent>" + "<extent>size2[4]</extent>" + "<extent>extent3[5]</extent>" + "<internetMediaType>m</internetMediaType>" + "</physicalDescription>" + "</mods>"; ModsDefinition mods = ModsUtils.unmarshal(xml, ModsDefinition.class); List<ArrayItem> expectedItems = Arrays.asList( new ExtentItem(0, "extent1[0]"), new ExtentItem(1, "size1[1]"), new ExtentItem(2, "extent2[3]"), new ExtentItem(3, "size2[4]"), new ExtentItem(4, "extent3[5]"), new NoteItem(5, "", null) ); PhysicalDescriptionMapper instance = new PhysicalDescriptionMapper(); List<ArrayItem> result = instance.map(mods); assertThat(result, Is.is(expectedItems)); }
public List<ArrayItem> map(ModsDefinition mods) { Optional<PhysicalDescriptionDefinition> pd = mods.getPhysicalDescription().stream().findFirst(); if (!pd.isPresent()) { return new ArrayList<>(); } ArrayList<Object> items = new ArrayList<>(); items.addAll(pd.get().getExtent()); items.addAll(pd.get().getNote()); return arrayMapper.map(items); }
PhysicalDescriptionMapper { public List<ArrayItem> map(ModsDefinition mods) { Optional<PhysicalDescriptionDefinition> pd = mods.getPhysicalDescription().stream().findFirst(); if (!pd.isPresent()) { return new ArrayList<>(); } ArrayList<Object> items = new ArrayList<>(); items.addAll(pd.get().getExtent()); items.addAll(pd.get().getNote()); return arrayMapper.map(items); } }
PhysicalDescriptionMapper { public List<ArrayItem> map(ModsDefinition mods) { Optional<PhysicalDescriptionDefinition> pd = mods.getPhysicalDescription().stream().findFirst(); if (!pd.isPresent()) { return new ArrayList<>(); } ArrayList<Object> items = new ArrayList<>(); items.addAll(pd.get().getExtent()); items.addAll(pd.get().getNote()); return arrayMapper.map(items); }  }
PhysicalDescriptionMapper { public List<ArrayItem> map(ModsDefinition mods) { Optional<PhysicalDescriptionDefinition> pd = mods.getPhysicalDescription().stream().findFirst(); if (!pd.isPresent()) { return new ArrayList<>(); } ArrayList<Object> items = new ArrayList<>(); items.addAll(pd.get().getExtent()); items.addAll(pd.get().getNote()); return arrayMapper.map(items); }  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 List<ArrayItem> map(ModsDefinition mods) { Optional<PhysicalDescriptionDefinition> pd = mods.getPhysicalDescription().stream().findFirst(); if (!pd.isPresent()) { return new ArrayList<>(); } ArrayList<Object> items = new ArrayList<>(); items.addAll(pd.get().getExtent()); items.addAll(pd.get().getNote()); return arrayMapper.map(items); }  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);  }