1

I'd like to persist a bare Map to vertex properties. The motivation is that I don't know in advance which properties the map will contain. And storing one vertex per property doesn't seem effective. How would I do that?

interface Foo {
    @Properties...?
    Map<String,String> getProperties();

    @Properties
    Map<String,String> addProperty();
}

Perhaps through method handlers. How? And is there any native support?

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277

1 Answers1

1

I've added support for it using the handlers. See the Windup project. https://github.com/windup/windup/pull/157

This is how it looks in models.

This one stores the map in the props of given frame's vertex, using a prefix map:

@TypeValue("MapInAdjPropsModelMain")
public interface MapMainModel extends WindupVertexFrame
{
    @InProperties(propPrefix = "map") void setMap(Map<String, String> map);

    @InProperties(propPrefix = "map") Map<String, String> getMap();
}

And this one stores the map in an adjacent vertex, hence can store multiple maps:

@TypeValue("MapInAdjPropsModelMain")
public interface MapMainModel extends WindupVertexFrame
{
    @InAdjacentProperties(edgeLabel = "map")
    void setMap(Map<String, String> map);

    @InAdjacentProperties(edgeLabel = "map")
    Map<String, String> getMap();

    @InAdjacentProperties(edgeLabel = "map2")
    void setMap2(Map<String, String> map);

    @InAdjacentProperties(edgeLabel = "map2")
    Map<String, String> getMap2();
}
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277