Have a function that takes an Object
type as parameter, I want to use this function by passing a Map<String, String>
variable. Unfortunately got complaints for that. Is there a way to cast Map<String, String>
to Object
? I thought any type of class can be automatically casted to Object since Object is the super class of everything.
This is the code:
private GeometryWithTags getRouteGeometryWithTags(Route route)
{
Map<String, Map<String, String>> edgesTags = new HashMap<>();
Iterator<Edge> edgeIterator = route.iterator();
while (edgeIterator.hasNext())
{
Edge edge = edgeIterator.next();
edgesTags.put(new Long(edge.getIdentifier()).toString(), edge.getTags());
}
return new GeometryWithTags(route.asPolyLine(), edgesTags);
}
error: incompatible types: Map> cannot be converted to Map return new GeometryWithTags(route.asPolyLine(), edgesTags);