// this could be handled by method overloading on Vertex public boolean isWheelchairAccessible(Vertex v) { if (v instanceof TransitStop) { TransitStop ts = (TransitStop) v; return ts.hasWheelchairEntrance(); } else if (v instanceof StreetLocation) { StreetLocation sl = (StreetLocation) v; return sl.isWheelchairAccessible(); } return true; }