当前位置: 首页>>代码示例>>Java>>正文


Java AbstractParam类代码示例

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


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


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