本文整理汇总了Java中org.raml.model.parameter.UriParameter类的典型用法代码示例。如果您正苦于以下问题:Java UriParameter类的具体用法?Java UriParameter怎么用?Java UriParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriParameter类属于org.raml.model.parameter包,在下文中一共展示了UriParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
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);
}
示例2: createApi
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
@Override
public String createApi(Raml raml, String name, JSONObject config) {
this.config = config;
// TODO: What to use as description?
final RestApi api = createApi(getApiName(raml, name), null);
LOG.info("Created API "+api.getId());
try {
final Resource rootResource = getRootResource(api).get();
deleteDefaultModels(api);
createModels(api, raml.getSchemas(), false);
createResources(api, createResourcePath(api, rootResource, raml.getBasePath()),
new HashMap<String, UriParameter>(), raml.getResources(), false);
} catch (Throwable t) {
LOG.error("Error creating API, rolling back", t);
rollback(api);
throw t;
}
return api.getId();
}
示例3: checkPathOnlyContainsParams
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
private boolean checkPathOnlyContainsParams(Resource childResource)
{
String uri = childResource.getRelativeUri();
// replace all params and their enclosing curly brackets with emmpty string
// also replace "/" with empty string, the remainder is the name, which can be
// an empty string if path consists entirely of uri params
uri = StringUtils.substitute(uri, "/", "");
Map<String, UriParameter> params = childResource.getUriParameters();
for (String paramName : params.keySet())
{
uri = StringUtils.substitute(uri, "{"+paramName+"}", "");
}
if (uri.trim().equals(""))
{
uri=null;
}
return uri==null;
}
示例4: addUriParameter
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
@Override
public EndpointRoute addUriParameter(String key, String description, String example) {
UriParameter param = new UriParameter(key);
param.setDescription(description);
param.setExample(example);
uriParameters.put(key, param);
return this;
}
示例5: apply
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
@Override
public void apply(UriParameter param, ResourceClassBuilder resourceClassBuilder) {
resourceClassBuilder.getApiClass().withMethod(
new AddPathParamMethod(param, param.getDisplayName(),
resourceClassBuilder.getReq(),
resourceClassBuilder.getApiClass()));
resourceClassBuilder.getDefaultsMethod().forParamDefaults(param.getDisplayName(), param);
}
示例6: getProperty
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
@Override
public Object getProperty(Interpreter interp, ST self, Object o, Object property, String propertyName) throws STNoSuchPropertyException {
final Resource res = (Resource) o;
switch (propertyName) {
case "resolvedUriParameters":
final Map<String, UriParameter> params = new TreeMap<>();
getAllResources(res, params);
return params;
case "actions":
return new TreeMap<>(res.getActions());
default:
return super.getProperty(interp, self, o, property, propertyName);
}
}
示例7: updateApi
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
@Override
public void updateApi(String apiId, Raml raml, JSONObject config) {
this.config = config;
RestApi api = getApi(apiId);
Optional<Resource> rootResource = getRootResource(api);
createModels(api, raml.getSchemas(), true);
createResources(api, createResourcePath(api, rootResource.get(), raml.getBasePath()),
new HashMap<String, UriParameter>(), raml.getResources(), true);
cleanupResources(api, this.paths);
cleanupModels(api, this.models);
}
示例8: createResources
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
private void createResources(RestApi api, Resource rootResource, Map<String, UriParameter> ancestorRequestParameters,
Map<String, org.raml.model.Resource> resources, boolean update) {
for (Map.Entry<String, org.raml.model.Resource> entry : resources.entrySet()) {
final org.raml.model.Resource resource = entry.getValue();
final Resource parentResource = createResourcePath(api, rootResource, entry.getKey());
Map<String, UriParameter> requestParameters = new HashMap<String, UriParameter>(resource.getUriParameters());
requestParameters.putAll(ancestorRequestParameters);
createMethods(api, parentResource, requestParameters, resource.getActions(), update);
createResources(api, parentResource, requestParameters, resource.getResources(), update);
}
}
示例9: createMethods
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
private void createMethods(RestApi api, Resource resource, Map<String, UriParameter> requestParameters,
Map<ActionType, Action> actions, boolean update) {
for (Map.Entry<ActionType, Action> entry : actions.entrySet()) {
createMethod(api, resource, entry.getKey(), entry.getValue(), requestParameters, update);
}
if (update) {
cleanupMethods(resource, actions);
}
}
示例10: getParameters
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
@Override
protected Map<String, ? extends AbstractParam> getParameters() {
if (!expectation().hasValidResource())
return new HashMap<>();
Map<String, UriParameter> parameters = expectation().getResource().get().getResolvedUriParameters();
return parameters == null ? new HashMap<>() : parameters;
}
示例11: isExpectationFor
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
public boolean isExpectationFor(Resource resource) {
List<String> uriValues = Arrays.asList(StringUtils.split(request.getPath().getValue(), "/"));
List<UriTemplateComponent> uriComponents = new UriTemplateParser().scan(resource.getUri());
if (uriValues.size() != uriComponents.size())
return false;
Map<UriTemplateComponent, String> componentValues = newHashMap();
for (int i = 0; i < uriComponents.size(); i++)
componentValues.put(uriComponents.get(i), uriValues.get(i));
Map<String, UriParameter> parameters = newHashMap();
resource.getResolvedUriParameters().entrySet()
.stream()
.forEach(e -> parameters.put(String.format("{%s}", e.getKey()), e.getValue()));
return componentValues.entrySet()
.stream()
.allMatch(e -> {
UriTemplateComponent component = e.getKey();
String value = e.getValue();
if (component instanceof Literal) {
return StringUtils.replace(component.getValue(), "/", "").equals(value);
} else {
return parameters.containsKey(component.getValue());
}
});
}
示例12: uriParameter
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
private Map<String, UriParameter> uriParameter(boolean required, boolean repeatable) {
UriParameter parameter = new UriParameter();
parameter.setRequired(required);
parameter.setRepeat(repeatable);
parameter.setType(ParamType.INTEGER);
Map<String, UriParameter> parameters = new HashMap<>();
parameters.put("ttl", parameter);
return parameters;
}
示例13: fromBaseToUri
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
public static Map<String, UriParameter> fromBaseToUri(Map<String, List<UriParameter>> aMap) {
Map<String, UriParameter> oParams=new HashMap<String, UriParameter>();
for (Map.Entry<String, List<UriParameter>> oE:aMap.entrySet()) {
oParams.put(oE.getKey(), oE.getValue().get(0));
}
return oParams;
}
示例14: extractResourceNameFromUriPath
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
private String extractResourceNameFromUriPath(Resource childResource)
{
String uri = childResource.getRelativeUri();
// replace all params and their enclosing curly brackets with emmpty string
Map<String, UriParameter> params = childResource.getUriParameters();
for (String paramName : params.keySet())
{
uri = StringUtils.substitute(uri, "{"+paramName+"}", "");
}
// find a string after a slash, starting with the last slash. Whena struing is found, this
// is the candidate bresource name
String resourceName = null;
while (uri.lastIndexOf("/")>-1)
{
int lastSlashPos = uri.lastIndexOf("/");
if (uri.length()>lastSlashPos+1)
{
resourceName = uri.substring(lastSlashPos+1);
break;
}
else if (lastSlashPos>0)
{
// reduce uri to part before this slash
uri = uri.substring(0,lastSlashPos);
}
else
{
break;
}
}
return resourceName;
}
示例15: convertUriParameterMap
import org.raml.model.parameter.UriParameter; //导入依赖的package包/类
public List<ch.alv.components.web.api.config.UriParameter> convertUriParameterMap(Map<String, UriParameter> uriParameters) {
List<ch.alv.components.web.api.config.UriParameter> list = new ArrayList<>();
for (String key : uriParameters.keySet()) {
list.add(convertUriParameter(uriParameters.get(key)));
}
return list;
}