• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AbstractParam类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.raml.model.parameter.AbstractParam的典型用法代码示例。如果您正苦于以下问题:Java AbstractParam类的具体用法?Java AbstractParam怎么用?Java AbstractParam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AbstractParam类属于org.raml.model.parameter包,在下文中一共展示了AbstractParam类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: forParamDefaults

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
public DefaultsMethod forParamDefaults(String name, AbstractParam param) {
    if (isEmpty(param.getDefaultValue())) {
        return this;
    }

    CodeBlock.Builder builder = builder();
    switch (Param.byClass(param.getClass())) {
        case URI_PARAM:
            builder.addStatement("$N.addPathParam($S, $S)", req.name(), name, param.getDefaultValue());
            break;
        case QUERY:
            builder.addStatement("$N.addQueryParam($S, $S)", req.name(), name, param.getDefaultValue());
            break;
        case FORM:
            builder.addStatement("$N.addParam($S, $S)", req.name(), name, param.getDefaultValue());
            break;
        case HEADER:
            builder.addStatement("$N.addHeader($S, $S)", req.name(), name, param.getDefaultValue());
    }

    defaults.add(builder.build());
    return this;
}
 
开发者ID:qameta,项目名称:rarc,代码行数:24,代码来源:DefaultsMethod.java


示例2: initSTGroup

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
private STGroupDir initSTGroup(Raml raml) {
    final STGroupDir group = loadGroupDir("guru/nidi/raml/doc/st-templates");

    group.registerModelAdaptor(Map.class, new EntrySetMapModelAdaptor());
    group.registerModelAdaptor(Raml.class, new RamlAdaptor());
    group.registerModelAdaptor(Resource.class, new ResourceAdaptor());
    group.registerModelAdaptor(Action.class, new ActionAdaptor(raml));
    group.registerModelAdaptor(SecuritySchemeDescriptor.class, new SecuritySchemeDescriptorAdaptor());
    group.registerModelAdaptor(Response.class, new ResponseAdaptor());

    group.registerRenderer(String.class, new StringRenderer(raml, config.getResourceCache()));
    group.registerRenderer(AbstractParam.class, new ParamRenderer());
    group.registerRenderer(Raml.class, new RamlRenderer());

    return group;
}
 
开发者ID:nidi3,项目名称:raml-doc,代码行数:17,代码来源:Generator.java


示例3: verifyParameters

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
private ValidationErrors verifyParameters(String parameterType,
                                          String name,
                                          KeyToMultiValue parameter,
                                          AbstractParam specification) {
    ValidationErrors errors = new ValidationErrors();

    if (parameter.getValues().size() > 1)
        errors.addMessage("[ security ] [ %s ] [ %s ] Only one value allowed for security parameters but multiple found.", parameterType, name);

    parameter.getValues().stream()
            .forEach(v -> {
                if (!specification.validate(v.getValue()))
                    errors.addMessage("[ security ] [ %s ] [ %s ] Value of [ %s ] does not meet API requirements.", parameterType, name, v.getValue());
            });

    return errors;
}
 
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:18,代码来源:RequestSecurityValidator.java


示例4: getValueParam

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
public static String getValueParam(AbstractParam aParam, String aName, String aWarning) {
	if(aParam.getExample()!=null) {
		String oReturn = aParam.getExample();
		if(oReturn.endsWith("\n")) {
			oReturn=oReturn.substring(0, oReturn.length()-1);
		}
		return oReturn;
	}
	if(aParam.getDefaultValue()!=null) {
		return aParam.getDefaultValue();
	}
	if(!aParam.getEnumeration().isEmpty()) {
		return aParam.getEnumeration().get(0);
	}
	logger.warn(aWarning + "- No exemple or default value for: " + aName);
	return aName;
}
 
开发者ID:pagesjaunes,项目名称:raml-codegen,代码行数:18,代码来源:Resolver.java


示例5: parameters

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
public void parameters(Map<String, ?> params, ParamName paramName) {
    if (paramName == ParamName.BASE_URI) {
        baseUriParameters(params.keySet());
    }
    if (parameterPattern != null) {
        for (final String name : params.keySet()) {
            if (!parameterPattern.matcher(name).matches()) {
                violation("parameter.name.invalid", locator, name, paramName, parameterPattern.pattern());
            }
        }
    }
    if (has(Validation.PARAMETER)) {
        parameterDef(params, paramName);
    }
    if (has(Validation.EXAMPLE)) {
        final ParameterChecker checker = new ParameterChecker(violations);
        for (final Map.Entry<String, AbstractParam> param : paramEntries(params)) {
            parameterValues(param.getValue(), checker, new Message("parameter.condition", locator, param.getKey(), paramName));
        }
    }
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:22,代码来源:RamlValidatorChecker.java


示例6: parameterDef

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
private void parameterDef(Map<String, ?> params, ParamName paramName) {
    for (final Map.Entry<String, AbstractParam> entry : paramEntries(params)) {
        final String name = entry.getKey();
        final AbstractParam param = entry.getValue();
        final ParamType type = param.getType() == null ? ParamType.STRING : param.getType();
        if (type == ParamType.STRING) {
            minMaxNotAllowed(param, name, paramName);
        } else {
            stringConstraintsNotAllowed(param, name, paramName);
            if (type != ParamType.INTEGER && type != ParamType.NUMBER) {
                minMaxNotAllowed(param, name, paramName);
            }
            if (type == ParamType.FILE) {
                violations.addIf(paramName != ParamName.FORM, new Message("parameter.file.illegal", locator, name, paramName));
            }
        }
    }
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:19,代码来源:RamlValidatorChecker.java


示例7: checkStringParameter

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
private void checkStringParameter(AbstractParam param, String value, Message detail) {
    switch (param.getType()) {
        case BOOLEAN:
            checkBoolean(value, detail);
            break;
        case DATE:
            checkDate(value, detail);
            break;
        case FILE:
            checkFile(detail);
            break;
        case INTEGER:
            checkInteger(param, value, detail);
            break;
        case NUMBER:
            checkNumber(param, value, detail);
            break;
        case STRING:
            checkString(param, value, detail);
            break;
        default:
            throw new RamlCheckerException("Unhandled parameter type '" + param.getType() + "'");
    }
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:25,代码来源:ParameterChecker.java


示例8: toString

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
@Override
public String toString(Object o, String formatString, Locale locale) {
    final AbstractParam param = (AbstractParam) o;
    String s = "";
    switch (formatString) {
        case "intLimit":
            if (param.getMinimum() != null) {
                s += param.getMinimum() + "<=";
            }
            if (param.getMinimum() != null || param.getMaximum() != null) {
                s += "x";
            }
            if (param.getMaximum() != null) {
                s += "<=" + param.getMaximum();
            }
            return s;
        case "strLimit":
            if (param.getMinLength() != null) {
                s += param.getMinLength() + "<=";
            }
            if (param.getMinLength() != null || param.getMaxLength() != null) {
                s += "length";
            }
            if (param.getMaxLength() != null) {
                s += "<=" + param.getMaxLength();
            }
            return s;
        case "type":
            return (param.getType() == null
                    ? "string"
                    : param.getType().toString().toLowerCase()) +
                    (param.isRequired()
                            ? param.isRepeat() ? "+" : ""
                            : param.isRepeat() ? "*" : "?");
        case "enum":
            return StringUtils.join(param.getEnumeration(), ", ");
        default:
            throw new IllegalArgumentException("unknown format '" + formatString + "'");
    }
}
 
开发者ID:nidi3,项目名称:raml-doc,代码行数:41,代码来源:ParamRenderer.java


示例9: getParameters

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
@Override
protected Map<String, ? extends AbstractParam> getParameters() {
    if (!expectation().hasValidAction())
        return new HashMap<>();

    Map<String, org.raml.model.parameter.Header> headers = expectation().getAction().get().getHeaders();
    return headers == null ? new HashMap<>() : headers;
}
 
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:9,代码来源:RequestHeaderParametersValidator.java


示例10: getParameters

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
@Override
protected Map<String, ? extends AbstractParam> getParameters() {
    if (!expectation().hasValidAction())
        return new HashMap<>();

    Map<String, QueryParameter> parameters = expectation().getAction().get().getQueryParameters();
    return parameters == null ? new HashMap<>() : parameters;
}
 
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:9,代码来源:RequestQueryParametersValidator.java


示例11: validate

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
@Override
public ValidationErrors validate() {
    ValidationErrors errors = new ValidationErrors();

    if (!this.expectation.hasValidAction())
        throw new NoValidActionException(expectation);

    Map<String, ? extends AbstractParam> parameters = getParameters();
    if (parameters.isEmpty()) return errors;

    parameters.entrySet().stream()
            .forEach(p -> {
                String name = p.getKey();
                AbstractParam parameter = p.getValue();
                List<NottableString> values = getValues(p.getKey());

                if (!parameter.isRequired() && values.isEmpty())
                    return;

                if (parameter.isRequired() && values.isEmpty()) {
                    errors.addMessage("[ %s ] [ %s ] [ %s ] Parameter is compulsory but no value(s) provided.", actionType, parameterType, name);
                    return;
                }

                if (!parameter.isRepeat() && values.size() > 1)
                    errors.addMessage("[ %s ] [ %s ] [ %s ] Only one value allowed but multiple values provided.", actionType, parameterType, name);

                values.stream()
                        .forEach(v -> {
                            if (!parameter.validate(v.getValue()))
                                errors.addMessage("[ %s ] [ %s ] [ %s ] Value of [ %s ] does not meet API requirements.", actionType, parameterType, name, v.getValue());
                        });
            });

    return errors;
}
 
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:37,代码来源:ParametersValidator.java


示例12: getParameters

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
@Override
protected Map<String, ? extends AbstractParam> getParameters() {
    if (!expectation().hasValidResponse())
        return new HashMap<>();

    Map<String, org.raml.model.parameter.Header> headers = expectation().getResponse().get().getHeaders();
    return headers == null ? new HashMap<>() : headers;
}
 
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:9,代码来源:ResponseHeaderParametersValidator.java


示例13: getParameters

import org.raml.model.parameter.AbstractParam; //导入依赖的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;
}
 
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:9,代码来源:RequestUriParametersValidator.java


示例14: resolve

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
public static <E extends AbstractParam> String resolve(String aUrl, Map<String,E> aParams, String aLogHeader) {
	Map<String, String> oMap=new HashMap<String, String>();
	for(Map.Entry<String, E> oE:aParams.entrySet()) {
		String oValue=getValueParam(oE.getValue(), oE.getKey(), aLogHeader);
		oMap.put(oE.getKey(), Utils.encode(oValue));
	}
	return Utils.resolve(aUrl, oMap);
}
 
开发者ID:pagesjaunes,项目名称:raml-codegen,代码行数:9,代码来源:Resolver.java


示例15: mapBaseParameterValues

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
public BaseParameter mapBaseParameterValues(AbstractParam source, BaseParameter target) {
    target.setName(convertName(source.getDisplayName()));
    target.setDescription(convertDescription(source.getDescription()));
    target.setType(convertParameterType(source.getType()));
    target.setPattern(convertPattern(source.getPattern()));
    return target;
}
 
开发者ID:alv-ch,项目名称:alv-ch-java,代码行数:8,代码来源:RamlConverter.java


示例16: checkFormParameters

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
private void checkFormParameters(Action action, Values values, MimeType mimeType) {
    if (mimeType.getSchema() != null) {
        requestViolations.add("schema.superfluous", locator);
    }
    @SuppressWarnings("unchecked")
    final Map<String, List<? extends AbstractParam>> formParameters = (Map) mimeType.getFormParameters();
    if (formParameters == null || formParameters.isEmpty()) {
        requestViolations.add("formParameters.missing", locator);
    } else {
        checkFormParametersValues(action, mimeType, values, formParameters);
    }
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:13,代码来源:RamlChecker.java


示例17: checkUriParams

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
private void checkUriParams(Values values, Resource resource) {
    final ParameterChecker paramChecker = new ParameterChecker(requestViolations).acceptUndefined();
    for (final Map.Entry<String, List<Object>> entry : values) {
        final AbstractParam uriParam = findUriParam(entry.getKey(), resource);
        final Message message = new Message("uriParam", locator, entry.getKey());
        if (uriParam != null) {
            paramChecker.checkParameter(uriParam, entry.getValue().get(0), message);
        }
    }
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:11,代码来源:RamlChecker.java


示例18: findUriParam

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
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;
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:11,代码来源:CheckerHelper.java


示例19: getEffectiveBaseUriParams

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
public static Map<String, List<? extends AbstractParam>> getEffectiveBaseUriParams(Map<String, UriParameter> baseUriParams, Action action) {
    final Map<String, List<? extends AbstractParam>> params = new HashMap<>();
    if (action.getBaseUriParameters() != null) {
        params.putAll(action.getBaseUriParameters());
    }
    addNotSetBaseUriParams(action.getResource(), params);
    if (baseUriParams != null) {
        for (final Map.Entry<String, UriParameter> entry : baseUriParams.entrySet()) {
            if (!params.containsKey(entry.getKey())) {
                params.put(entry.getKey(), Collections.singletonList(entry.getValue()));
            }
        }
    }
    return params;
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:16,代码来源:CheckerHelper.java


示例20: addNotSetBaseUriParams

import org.raml.model.parameter.AbstractParam; //导入依赖的package包/类
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);
    }
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:13,代码来源:CheckerHelper.java



注:本文中的org.raml.model.parameter.AbstractParam类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityCreeper类代码示例发布时间:2022-05-22
下一篇:
Java MotorSafetyHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap