public static AbstractParam findUriParam(String uriParam, Resource resource) { final UriParameter param = resource.getUriParameters().get(uriParam); if (param != null) { return param; } if (resource.getParentResource() != null) { return findUriParam(uriParam, resource.getParentResource()); } return null; }
public void getAllResources(Resource resource, Map<String, UriParameter> res) { res.putAll(resource.getUriParameters()); if (resource.getParentResource() != null) { getAllResources(resource.getParentResource(), res); } }
private static void addNotSetBaseUriParams(Resource resource, Map<String, List<? extends AbstractParam>> params) { if (resource.getBaseUriParameters() != null) { for (final Map.Entry<String, List<UriParameter>> entry : resource.getBaseUriParameters().entrySet()) { if (!params.containsKey(entry.getKey())) { params.put(entry.getKey(), entry.getValue()); } } } if (resource.getParentResource() != null) { addNotSetBaseUriParams(resource.getParentResource(), params); } }
private void addAllResourcePathParameters(Resource resource, final JMethod method, final JDocComment javadoc) throws Exception { for (final Entry<String, UriParameter> namedUriParameter : resource .getUriParameters().entrySet()) { addParameter(namedUriParameter.getKey(), namedUriParameter.getValue(), PathParam.class, method, javadoc); } Resource parentResource = resource.getParentResource(); if (parentResource != null) { addAllResourcePathParameters(parentResource, method, javadoc); } }
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
/** * Returns the list of * {@link org.restlet.ext.apispark.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.apispark.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
private void addAllResourcePathParameters(Resource resource, final JMethod method, final JDocComment javadoc) throws Exception { for (final Entry<String, UriParameter> namedUriParameter : resource .getUriParameters() .entrySet()) { addParameter(namedUriParameter.getKey(), namedUriParameter.getValue(), PathParam.class, method, javadoc); } Resource parentResource = resource.getParentResource(); if (parentResource != null ) { addAllResourcePathParameters(parentResource, method, javadoc); } }
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
/** * Returns the list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as defined * by the given {@link org.raml.model.Resource}. * * @param resource * The given resource. * @return The list of * {@link org.restlet.ext.platform.internal.model.PathVariable} as * defined by the given {@link org.raml.model.Resource}. */ private static List<PathVariable> getPathVariables( org.raml.model.Resource resource) { List<PathVariable> pathVariables = new ArrayList<>(); for (Entry<String, UriParameter> entry : resource.getUriParameters() .entrySet()) { pathVariables .add(getPathVariable(entry.getKey(), entry.getValue())); } if (resource.getParentResource() != null) { pathVariables .addAll(getPathVariables(resource.getParentResource())); } return pathVariables; }
public static String className(Resource resource) { return "Api" + classPart(resource.getParentResource()) + classPart(resource); }
public void generate() { if (resource.getParentResource() != null && !resource.getParentResource().getUriParameters().isEmpty()) { Map<String, UriParameter> combined = new HashMap<>(); combined.putAll(resource.getParentResource().getUriParameters()); combined.putAll(resource.getUriParameters()); resource.setUriParameters(combined); } resource.getResources().values().stream().forEach(generateResourceClasses); uri = new UriConst(resource.getUri()); apiClass = ApiResourceClass.forResource(resource) .withField(uri) .withField(req) .withField(resp); responseParser = respParserForResource(resource); defaultsMethod = new DefaultsMethod(apiClass, req); new ResourceRule().apply(resource, this); javaFiles.stream().forEach(writeTo); }
if (ramlResource.getParentResource() != null) procreate(ramlResource.getParentResource(), codeModelHook, context);