org.apache.cloudstack.api.Parameter.name()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中org.apache.cloudstack.api.Parameter.name()方法的一些代码示例,展示了Parameter.name()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parameter.name()方法的具体详情如下:
包路径:org.apache.cloudstack.api.Parameter
类名称:Parameter
方法名:name

Parameter.name介绍

暂无

代码示例

代码示例来源:origin: apache/cloudstack

protected List<String> getParamNamesForCommand(final BaseCmd cmd) {
    final List<String> paramNames = new ArrayList<String>();
    // The expected param names are all the specific for the current command class ...
    for (final Field field : cmd.getParamFields()) {
      final Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
      paramNames.add(parameterAnnotation.name());
    }
    // ... plus the default ones
    paramNames.addAll(defaultParamNames);
    return paramNames;
  }
}

代码示例来源:origin: apache/cloudstack

public static void set(BaseCmd cmd, String fieldName, Object value)
    throws IllegalArgumentException, IllegalAccessException {
  for (Field field : cmd.getClass().getDeclaredFields()) {
    Parameter parameter = field.getAnnotation(Parameter.class);
    if (parameter != null && fieldName.equals(parameter.name())) {
      field.setAccessible(true);
      field.set(cmd, value);
    }
  }
}

代码示例来源:origin: apache/cloudstack

validFields.add(field);
} else {
  s_logger.debug("Ignoring paremeter " + parameterAnnotation.name() + " as the caller is not authorized to pass it in");

代码示例来源:origin: apache/cloudstack

continue;
Object paramObj = parameterMap.get(parameterAnnotation.name());
if (paramObj != null) {
  if (!parameterAnnotation.acceptedOnAdminPort()) {
    throw new ServerApiException(ApiErrorCode.ACCOUNT_ERROR, "Parameter " + parameterAnnotation.name() + " can't be passed through the API integration port");

代码示例来源:origin: apache/cloudstack

CallContext.current().putContextParameter(entity, internalId);
    validateNaturalNumber(internalId, annotation.name());
    return internalId;
  if (s_logger.isDebugEnabled())
    s_logger.debug("Object entity uuid = " + uuid + " does not exist in the database.");
  throw new InvalidParameterValueException("Invalid parameter " + annotation.name() + " value=" + uuid +
      " due to incorrect long value format, or entity does not exist or due to incorrect parameter annotation for the field in api cmd class.");
validateNaturalNumber(internalId, annotation.name());
return internalId;

代码示例来源:origin: apache/cloudstack

Parameter parameterAnnotation = f.getAnnotation(Parameter.class);
if (parameterAnnotation != null && parameterAnnotation.expose() && parameterAnnotation.includeInApiDoc()) {
  Argument reqArg = new Argument(parameterAnnotation.name());
  reqArg.setRequired(parameterAnnotation.required());
  if (!parameterAnnotation.description().isEmpty()) {
    if (parameterAnnotation.name().equals("id")) {
      id = reqArg;
    } else {

代码示例来源:origin: apache/cloudstack

final Object paramObj = params.get(parameterAnnotation.name());
if (paramObj == null) {
  if (parameterAnnotation.required()) {
    throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " +
        cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) +
        " due to missing parameter " + parameterAnnotation.name());
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("Unable to execute API command " + cmd.getCommandName() + " due to invalid value " + paramObj + " for parameter " +
        parameterAnnotation.name());
      parameterAnnotation.name());
} catch (final ParseException parseEx) {
  if (s_logger.isDebugEnabled()) {

代码示例来源:origin: apache/cloudstack

private void validateField(final Object paramObj, final Parameter annotation) throws ServerApiException {
  if (annotation == null) {
    return;
  }
  final String argName = annotation.name();
  for (final ApiArgValidator validator : annotation.validations()) {
    if (validator == null) {
      continue;
    }
    switch (validator) {
      case NotNullOrEmpty:
        switch (annotation.type()) {
          case UUID:
          case STRING:
            validateNonEmptyString(paramObj, argName);
            break;
        }
        break;
      case PositiveNumber:
        switch (annotation.type()) {
          case SHORT:
          case INTEGER:
          case LONG:
            validateNaturalNumber(paramObj, argName);
            break;
        }
        break;
    }
  }
}

代码示例来源:origin: apache/cloudstack

private ApiDiscoveryResponse getCmdRequestMap(Class<?> cmdClass, APICommand apiCmdAnnotation) {
  String apiName = apiCmdAnnotation.name();
  ApiDiscoveryResponse response = new ApiDiscoveryResponse();
  response.setName(apiName);
  response.setDescription(apiCmdAnnotation.description());
  if (!apiCmdAnnotation.since().isEmpty()) {
    response.setSince(apiCmdAnnotation.since());
  }
  Set<Field> fields = ReflectUtil.getAllFieldsForClass(cmdClass, new Class<?>[] {BaseCmd.class, BaseAsyncCmd.class, BaseAsyncCreateCmd.class});
  boolean isAsync = ReflectUtil.isCmdClassAsync(cmdClass, new Class<?>[] {BaseAsyncCmd.class, BaseAsyncCreateCmd.class});
  response.setAsync(isAsync);
  for (Field field : fields) {
    Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
    if (parameterAnnotation != null && parameterAnnotation.expose() && parameterAnnotation.includeInApiDoc()) {
      ApiParameterResponse paramResponse = new ApiParameterResponse();
      paramResponse.setName(parameterAnnotation.name());
      paramResponse.setDescription(parameterAnnotation.description());
      paramResponse.setType(parameterAnnotation.type().toString().toLowerCase());
      paramResponse.setLength(parameterAnnotation.length());
      paramResponse.setRequired(parameterAnnotation.required());
      if (!parameterAnnotation.since().isEmpty()) {
        paramResponse.setSince(parameterAnnotation.since());
      }
      paramResponse.setRelated(parameterAnnotation.entityType()[0].getName());
      response.addParam(paramResponse);
    }
  }
  return response;
}

相关文章