public InitializrMetadataV2JsonMapper() { this.templateVariables = new TemplateVariables( new TemplateVariable("dependencies", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("packaging", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("javaVersion", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("language", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("bootVersion", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("groupId", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("artifactId", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("version", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("name", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("description", TemplateVariable.VariableType.REQUEST_PARAM), new TemplateVariable("packageName", TemplateVariable.VariableType.REQUEST_PARAM)); }
public InitializrMetadataV21JsonMapper() { this.dependenciesVariables = new TemplateVariables(new TemplateVariable( "bootVersion", TemplateVariable.VariableType.REQUEST_PARAM)); }
/** * Creates a new {@link UriTemplate} with a {@link TemplateVariable} with the given name and type added. * * @param variableName must not be {@literal null} or empty. * @param type must not be {@literal null}. * @return will never be {@literal null}. */ public UriTemplate with(String variableName, TemplateVariable.VariableType type) { return with(new TemplateVariables(new TemplateVariable(variableName, type))); }
/** * Returns the {@link TemplateVariables} for all parameters of the given {@link MethodResourceMapping}. * * @param mapping must not be {@literal null}. * @return will never be {@literal null}. */ private TemplateVariables getParameterVariables(MethodResourceMapping mapping) { List<TemplateVariable> variables = new ArrayList<TemplateVariable>(); for (ParameterMetadata metadata : mapping.getParametersMetadata()) { variables.add(new TemplateVariable(metadata.getName(), VariableType.REQUEST_PARAM)); } return new TemplateVariables(variables); }
variable = new TemplateVariable(name.substring(0, name.length() - 1), VariableType.COMPOSITE_PARAM); } else { variable = new TemplateVariable(name, type);
/** * Returns the {@link TemplateVariables} for the projection parameter if projections are vonfigured for the given * type. * * @param type must not be {@literal null}. * @return will never be {@literal null}. */ private TemplateVariables getProjectionVariable(Class<?> type) { ProjectionDefinitionConfiguration projectionConfiguration = config.getProjectionConfiguration(); if (projectionConfiguration.hasProjectionFor(type)) { return new TemplateVariables(new TemplateVariable(projectionConfiguration.getParameterName(), REQUEST_PARAM)); } else { return TemplateVariables.NONE; } }
private TemplateVariables getProjectionVariable(PersistentProperty<?> property) { ProjectionDefinitionConfiguration projectionConfiguration = config.getProjectionConfiguration(); return projectionConfiguration.hasProjectionFor(property.getActualType()) // ? new TemplateVariables(new TemplateVariable(projectionConfiguration.getParameterName(), REQUEST_PARAM)) // : TemplateVariables.NONE; } }
TemplateVariable variable = new TemplateVariable(parameter, previousRequestParameter ? REQUEST_PARAM : REQUEST_PARAM_CONTINUED); variables = variables.concat(variable);
/** * Creates a new {@link UriTemplate} with a {@link TemplateVariable} with the given name and type added. * * @param variableName must not be {@literal null} or empty. * @param type must not be {@literal null}. * @return will never be {@literal null}. */ public UriTemplate with(String variableName, TemplateVariable.VariableType type) { return with(new TemplateVariables(new TemplateVariable(variableName, type))); }
/** * Returns the {@link TemplateVariables} for all parameters of the given {@link MethodResourceMapping}. * * @param mapping must not be {@literal null}. * @return will never be {@literal null}. */ private TemplateVariables getParameterVariables(MethodResourceMapping mapping) { List<TemplateVariable> variables = new ArrayList<TemplateVariable>(); for (ParameterMetadata metadata : mapping.getParametersMetadata()) { variables.add(new TemplateVariable(metadata.getName(), VariableType.REQUEST_PARAM)); } return new TemplateVariables(variables); }
/** * Creates a new {@link UriTemplate} using the given template string. * * @param template must not be {@literal null} or empty. */ public UriTemplate(String template) { Assert.hasText(template, "Template must not be null or empty!"); Matcher matcher = VARIABLE_REGEX.matcher(template); int baseUriEndIndex = template.length(); List<TemplateVariable> variables = new ArrayList<TemplateVariable>(); while (matcher.find()) { int start = matcher.start(0); VariableType type = VariableType.from(matcher.group(1)); String[] names = matcher.group(2).split(","); for (String name : names) { TemplateVariable variable = new TemplateVariable(name, type); if (!variable.isRequired() && start < baseUriEndIndex) { baseUriEndIndex = start; } variables.add(variable); } } this.variables = variables.isEmpty() ? TemplateVariables.NONE : new TemplateVariables(variables); this.baseUri = template.substring(0, baseUriEndIndex); }
/** * Returns the {@link TemplateVariables} for the projection parameter if projections are vonfigured for the given * type. * * @param type must not be {@literal null}. * @return will never be {@literal null}. */ private TemplateVariables getProjectionVariable(Class<?> type) { ProjectionDefinitionConfiguration projectionConfiguration = config.getProjectionConfiguration(); if (projectionConfiguration.hasProjectionFor(type)) { return new TemplateVariables(new TemplateVariable(projectionConfiguration.getParameterName(), REQUEST_PARAM)); } else { return TemplateVariables.NONE; } }
private TemplateVariables getProjectionVariable(PersistentProperty<?> property) { ProjectionDefinitionConfiguration projectionConfiguration = config.getProjectionConfiguration(); return projectionConfiguration.hasProjectionFor(property.getActualType()) // ? new TemplateVariables(new TemplateVariable(projectionConfiguration.getParameterName(), REQUEST_PARAM)) // : TemplateVariables.NONE; } }
List<Integer> variablesInPart = new ArrayList<Integer>(); for (String name : names) { TemplateVariable variable = new TemplateVariable(name, type); variablesInPart.add(variables.size()); variables.add(variable);
List<Integer> variablesInPart = new ArrayList<Integer>(); for (String name : names) { TemplateVariable variable = new TemplateVariable(name, type); variablesInPart.add(variables.size()); variables.add(variable);
/** * Returns the template variables for the sort parameter. * * @param parameter must not be {@literal null}. * @return * @since 1.7 */ public TemplateVariables getSortTemplateVariables(MethodParameter parameter, UriComponents template) { String sortParameter = getSortParameter(parameter); MultiValueMap<String, String> queryParameters = template.getQueryParams(); boolean append = !queryParameters.isEmpty(); if (queryParameters.containsKey(sortParameter)) { return TemplateVariables.NONE; } String description = String.format("pagination.%s.description", sortParameter); VariableType type = append ? REQUEST_PARAM_CONTINUED : REQUEST_PARAM; return new TemplateVariables(new TemplateVariable(sortParameter, type, description)); }
/** * Returns the template variable for the pagination parameters. * * @param parameter can be {@literal null}. * @return * @since 1.7 */ public TemplateVariables getPaginationTemplateVariables(MethodParameter parameter, UriComponents template) { String pagePropertyName = getParameterNameToUse(getPageParameterName(), parameter); String sizePropertyName = getParameterNameToUse(getSizeParameterName(), parameter); List<TemplateVariable> names = new ArrayList<>(); MultiValueMap<String, String> queryParameters = template.getQueryParams(); boolean append = !queryParameters.isEmpty(); for (String propertyName : Arrays.asList(pagePropertyName, sizePropertyName)) { if (!queryParameters.containsKey(propertyName)) { VariableType type = append ? REQUEST_PARAM_CONTINUED : REQUEST_PARAM; String description = String.format("pagination.%s.description", propertyName); names.add(new TemplateVariable(propertyName, type, description)); } } TemplateVariables pagingVariables = new TemplateVariables(names); return pagingVariables.concat(sortResolver.getSortTemplateVariables(parameter, template)); }
TemplateVariable variable = new TemplateVariable(parameter, previousRequestParameter ? REQUEST_PARAM : REQUEST_PARAM_CONTINUED); variables = variables.concat(variable);