GraphMLReader.load initializes the three (vertex, graph, edge) _metadata to an empty map just by calling load.
There are no setters, so users can't configure that data before calling load, but in addition, when calling load, it would be wiped clean again
Besides, it uses the Transformer in GraphMLMetadata as it was a SettableTransformer without checking, and the GraphMLMetadata allows for a non-SettableTransformer, thus allowing ClassCastExceptions
To repair this:
Either modify GraphMLMetadata to use SettableTransformer instead Transformer, or check its uses in GraphMLReader to avoid ClassCastException.
I think it's better to modify GraphMLMetadata because then it's assured to recover the details included
Change initializeData to private and call it in the constructor instead of in load()
Subsequent calls to load() will have no problem because load() calls clearData() and the rest of maps will be clean before starting a new load.
Another way is to put setters for the *_metadata and delete the lines that assign them empty maps
Anyway, the current version is redundant since initializeData creates several maps as empty maps, and just after it's called, clearData() cleans those empty maps.
Instead of changing GraphMLReader, let's say you have a particular GraphMLMetadata you want to apply.
After the load, the GraphMLReader has GraphMLMetadata, including a Transformer that can transform a particular object to the String the reader has read. If you have a SettableTransformer you want to use, you can use a method like this (for graph, you can use Collections.singleton(yourGraph))
private <t> void applyMetadata (Map<string, graphmlmetadata\<t="">> readMetadata,
Map<string, graphmlmetadata\<t="">> customMetadata, Collection<t> target){
if (customMetadata == null){
// there's no way to set the elements
return;
}
for (Entry<string, graphmlmetadata\<t="">> entrada : readMetadata.entrySet()){
GraphMLMetadata<t> custom = customMetadata.get(entrada.getKey());
if (custom != null){
// there's metadata for this field
if (custom.transformer instanceof SettableTransformer){
// there's a way to set the information
SettableTransformer<t, string=""> customTransformer = (SettableTransformer<t, string="">) custom.transformer;
Transformer<t, string=""> readedTransformer = entrada.getValue().transformer;</t,></t,></t,></t></string,></t></string,></string,></t>