/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }
/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }
/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }
/** * Gets the parent resource of a Resource given its path and the list of * paths available on the API. * * @param paths * The list of paths available on the API. * @param resourcePath * The path of the resource the parent resource is searched for. * @param raml * The RAML representing the API. * @return The parent resource. */ public static Resource getParentResource(List<String> paths, String resourcePath, Raml raml) { List<String> parentPaths = new ArrayList<String>(); parentPaths.addAll(paths); parentPaths.add(resourcePath); Collections.sort(parentPaths); int index = parentPaths.indexOf(resourcePath); if (index != 0) { String parentPath = parentPaths.get(index - 1); if (resourcePath.startsWith(parentPath)) { return getResourceByCompletePath(raml, parentPath); } } return null; }