* FIXME : singleton\r
* TODO : removing paths\r
* TODO : prevent adding same path multiple times\r
+ * TODO : how to handle multi-instances?\r
* \r
* \r
* @author Marko Luukkainen\r
private static PathContainer instance = new PathContainer();\r
\r
MapList<Resource, List<Resource>> paths;\r
+ //List<Pair<List<Resource>,List<Resource>>> multiInstancePaths;\r
\r
private PathContainer() {\r
paths = new MapList<Resource, List<Resource>>();\r
+ //multiInstancePaths = new ArrayList<Pair<List<Resource>,List<Resource>>>();\r
}\r
\r
public List<List<Resource>> getPaths(IEntity instance) {\r
Collection<IEntity> types = instance.getTypes();\r
- if (types.size() != 1)\r
- throw new UnsupportedOperationException("Multi-instances not supported!");\r
- Resource type = types.iterator().next().getResource();\r
- return paths.getValues(type);\r
+ if (types.size() != 1) {\r
+ // for multi-instances we check if any of the types have paths\r
+ // no we return paths for a single type (it is possible to combine paths for all types)\r
+ for (IEntity type : types) {\r
+ Resource r = type.getResource();\r
+ List<List<Resource>> path = paths.getValues(r);\r
+ if (path != null)\r
+ return path;\r
+ }\r
+ return null;\r
+ } else {\r
+ Resource type = types.iterator().next().getResource();\r
+ return paths.getValues(type);\r
+ }\r
}\r
\r
public void addPath(Resource type, List<Resource> path) {\r