/** * Identifies whether the given {@link Route} is a sub-route of this one. If the given * {@link Route} is greater than this {@link Route}, this method will return false. * * @param route * The {@link Route} to check * @return true if the given {@link Route} is a sub-route */ public boolean isSubRoute(final Route route) { return subRouteIndex(route) > -1; }
/** * Identifies whether any of the given {@link Route} is a sub-route of this one. * * @param routes * The {@link Iterable} of {@link Route}s to check * @return true if any of the given {@link Route}s is a sub-route. */ public boolean isSubRouteForAtLeastOneOf(final Iterable<Route> routes) { return subRouteIndex(routes) > -1; }
/** * Calculates the first occurring subRoute index from the given {@link Route}s. For details, see * {@link #subRouteIndex(Route)}. * * @param routes * The {@link Route}s to compare with * @return first occurring calculated index */ public int subRouteIndex(final Iterable<Route> routes) { for (final Route route : routes) { final int overlapIndex = subRouteIndex(route); if (overlapIndex > -1) { return overlapIndex; } } return -1; }
overlapIndex = route.subRouteIndex(this); overlapIndex = subRouteIndex(route);
final int fromSubRouteIndex = candidate.subRouteIndex(from); final int routeEndIndex = candidate.size() - 1;
shorterRoute.subRouteIndex(longerRoute)); Assert.assertFalse(shorterRoute.isSubRoute(longerRoute)); 1, longerRoute.subRouteIndex(shorterRoute)); Assert.assertTrue(longerRoute.isSubRoute(shorterRoute));