@Test public void testWriteRead() throws Exception { ModsDefinition mods = new ModsDefinition(); PeriodicalVolume value = new PeriodicalVolume(); value.setVolumeNumber("1"); value.setYear("1893"); value.setNote("note"); value.setIdentifiers(Arrays.asList(new IdentifierItem(null, "uuid", "1"))); PeriodicalVolumeMapper instance = new PeriodicalVolumeMapper(); instance.map(mods, value); String dump = ModsUtils.toXml(mods, true); PeriodicalVolume result = instance.map(ModsUtils.unmarshal(dump, ModsDefinition.class)); assertNotNull(result); assertEquals(value.getVolumeNumber(), result.getVolumeNumber()); assertEquals(value.getYear(), result.getYear()); assertEquals(value.getNote(), result.getNote()); assertEquals(Arrays.asList(new IdentifierItem(0, "uuid", "1")), result.getIdentifiers()); }
@Override public PeriodicalVolume map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); PeriodicalVolume volume = new PeriodicalVolume(); volume.setIdentifiers(identMap.map(mods)); if (nlookup.getPart(false) != null) { DateDefinition year = nlookup.getDate(false); volume.setYear(year == null ? null : year.getValue()); volume.setVolumeNumber(MapperUtils.toString(nlookup.getNumber(false))); Text note = nlookup.getNote(false); volume.setNote(note == null ? null : note.getValue()); } return volume; }
PeriodicalVolumeMapper implements Mapper<PeriodicalVolume> { @Override public PeriodicalVolume map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); PeriodicalVolume volume = new PeriodicalVolume(); volume.setIdentifiers(identMap.map(mods)); if (nlookup.getPart(false) != null) { DateDefinition year = nlookup.getDate(false); volume.setYear(year == null ? null : year.getValue()); volume.setVolumeNumber(MapperUtils.toString(nlookup.getNumber(false))); Text note = nlookup.getNote(false); volume.setNote(note == null ? null : note.getValue()); } return volume; } }
PeriodicalVolumeMapper implements Mapper<PeriodicalVolume> { @Override public PeriodicalVolume map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); PeriodicalVolume volume = new PeriodicalVolume(); volume.setIdentifiers(identMap.map(mods)); if (nlookup.getPart(false) != null) { DateDefinition year = nlookup.getDate(false); volume.setYear(year == null ? null : year.getValue()); volume.setVolumeNumber(MapperUtils.toString(nlookup.getNumber(false))); Text note = nlookup.getNote(false); volume.setNote(note == null ? null : note.getValue()); } return volume; }  }
PeriodicalVolumeMapper implements Mapper<PeriodicalVolume> { @Override public PeriodicalVolume map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); PeriodicalVolume volume = new PeriodicalVolume(); volume.setIdentifiers(identMap.map(mods)); if (nlookup.getPart(false) != null) { DateDefinition year = nlookup.getDate(false); volume.setYear(year == null ? null : year.getValue()); volume.setVolumeNumber(MapperUtils.toString(nlookup.getNumber(false))); Text note = nlookup.getNote(false); volume.setNote(note == null ? null : note.getValue()); } return volume; }  @Override PeriodicalVolume map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, PeriodicalVolume volume); }
PeriodicalVolumeMapper implements Mapper<PeriodicalVolume> { @Override public PeriodicalVolume map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); PeriodicalVolume volume = new PeriodicalVolume(); volume.setIdentifiers(identMap.map(mods)); if (nlookup.getPart(false) != null) { DateDefinition year = nlookup.getDate(false); volume.setYear(year == null ? null : year.getValue()); volume.setVolumeNumber(MapperUtils.toString(nlookup.getNumber(false))); Text note = nlookup.getNote(false); volume.setNote(note == null ? null : note.getValue()); } return volume; }  @Override PeriodicalVolume map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, PeriodicalVolume volume);  }