PluginId { @Override public String toString() { if (this.stringRepresentation == null) { StringBuilder stringRepresentation = new StringBuilder(uri.toString()); stringRepresentation.append('/'); stringRepresentation.append(version.toString()); this.stringRepresentation = stringRepresentation.toString(); } return this.stringRepresentation; } private  PluginId();  PluginId(URI uri, Version version);  PluginId(String uri, String version); URI getUri(); Version getVersion(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static PluginId parsePluginId(String string);  }
@Test public void shouldBeXmlSerializable() throws JAXBException { URI id = URI.create("http: Version version = new Version(1, 0, 1); PluginId pluginId = new PluginId(id, version); JAXBContext jaxbContext = JAXBContext.newInstance(PluginId.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); StringWriter stringWriter = new StringWriter(); marshaller.marshal(pluginId, stringWriter); assertThat(stringWriter.toString(), is("<pluginId uri=\"http: Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); StringReader stringReader = new StringReader(stringWriter.toString()); StreamSource source = new StreamSource(stringReader); JAXBElement<PluginId> jaxbElement = unmarshaller.unmarshal(source, PluginId.class); assertThat(jaxbElement.getValue(), equalTo(pluginId)); }