/** Required by Hibernate */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Trip other = (Trip) obj; if (blockId == null) { if (other.blockId != null) return false; } else if (!blockId.equals(other.blockId)) return false; if (configRev != other.configRev) return false; if (directionId == null) { if (other.directionId != null) return false; } else if (!directionId.equals(other.directionId)) return false; if (endTime == null) { if (other.endTime != null) return false; } else if (!endTime.equals(other.endTime)) return false; if (exactTimesHeadway != other.exactTimesHeadway) return false; if (headsign == null) { if (other.headsign != null) return false; } else if (!headsign.equals(other.headsign)) return false; if (noSchedule != other.noSchedule) return false; if (route == null) { if (other.route != null) return false; } else if (!route.equals(other.route)) return false; if (routeId == null) { if (other.routeId != null) return false; } else if (!routeId.equals(other.routeId)) return false; if (routeShortName == null) { if (other.routeShortName != null) return false; } else if (!routeShortName.equals(other.routeShortName)) return false; if (scheduledTimesList == null) { if (other.scheduledTimesList != null) return false; } else if (!scheduledTimesList.equals(other.scheduledTimesList)) return false; if (serviceId == null) { if (other.serviceId != null) return false; } else if (!serviceId.equals(other.serviceId)) return false; if (shapeId == null) { if (other.shapeId != null) return false; } else if (!shapeId.equals(other.shapeId)) return false; if (startTime == null) { if (other.startTime != null) return false; } else if (!startTime.equals(other.startTime)) return false; if (travelTimes == null) { if (other.travelTimes != null) return false; } else if (!travelTimes.equals(other.travelTimes)) return false; if (tripId == null) { if (other.tripId != null) return false; } else if (!tripId.equals(other.tripId)) return false; if (tripPattern == null) { if (other.tripPattern != null) return false; } else if (!tripPattern.equals(other.tripPattern)) return false; if (tripShortName == null) { if (other.tripShortName != null) return false; } else if (!tripShortName.equals(other.tripShortName)) return false; return true; }
/** Order is important when comparing route lists. */ public boolean equals(Object other) { if (!(other instanceof RouteList)) return false; RouteList that = (RouteList) other; if (this.size() != that.size()) return false; ListIterator<Route> it = this.listIterator(); ListIterator<Route> it1 = that.listIterator(); while (it.hasNext()) { Route route = (Route) it.next(); Route route1 = (Route) it1.next(); if (!route.equals(route1)) return false; } return true; }
@Override public List<RouteMatch> findRoutes(String requestUri, String requestMethod) { log.trace("Finding route matches for {} '{}'", requestMethod, requestUri); List<RouteMatch> routeMatches = new ArrayList<>(); List<PatternBinding> bindings = getBindings(requestMethod); for (Route route : routes) { // to preserve the routes order for (PatternBinding binding : bindings) { if (route.equals(binding.getRoute()) && binding.getPattern().matcher(requestUri).matches()) { // TODO improve (it's possible to have the same uriPattern for many routes => same // parameters) routeMatches.add(new RouteMatch(route, getParameters(binding, requestUri))); break; } } } log.debug("Found {} route matches for {} '{}'", routeMatches.size(), requestMethod, requestUri); return routeMatches; }