}
@Override
public void marshal(Object source, HierarchicalStreamWriter writer,
MarshallingContext context) {
GraphEdge edge = (GraphEdge) source;
Relation relation = edge.getRelation();
writer.startNode(RELATION_TAG);
Class<?> actualType = relation.getClass();
Class<?> defaultType = mapper.defaultImplementationOf(BasicEdge.class);
if (!actualType.equals(defaultType)) {
writer.addAttribute(
mapper.aliasForAttribute("class"),
mapper.serializedClass(actualType));
}
context.convertAnother(relation);
writer.endNode();
writer.startNode(HEAD_TAG);
context.convertAnother(edge.getHead().getId());
writer.endNode();
writer.startNode(TAIL_TAG);
context.convertAnother(edge.getTail().getId());
writer.endNode();
}