com.hortonworks.registries.common.QueryParam.getName()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(96)

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

QueryParam.getName介绍

暂无

代码示例

代码示例来源:origin: hortonworks/registry

/**
 * Uses reflection to query the field or the method. Assumes
 * a public getXXX method is available to get the field value.
 */
private boolean matches(Storable val, List<QueryParam> queryParams, Class<?> clazz) {
  Object fieldValue;
  boolean res = true;
    for (QueryParam qp : queryParams) {
      try {
        fieldValue = ReflectionHelper.invokeGetter(qp.name, val);
        if (!fieldValue.toString().equals(qp.value)) {
          return false;
        }
      } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
        LOG.error("FAILED to invoke getter for query param {} , is your param name correct?", qp.getName(), e);
        return false;
      }
    }
  return res;
}

代码示例来源:origin: com.hortonworks.registries/storage-core

/**
 * Uses reflection to query the field or the method. Assumes
 * a public getXXX method is available to get the field value.
 */
private boolean matches(Storable val, List<QueryParam> queryParams, Class<?> clazz) {
  Object fieldValue;
  boolean res = true;
    for (QueryParam qp : queryParams) {
      try {
        fieldValue = ReflectionHelper.invokeGetter(qp.name, val);
        if (!fieldValue.toString().equals(qp.value)) {
          return false;
        }
      } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
        LOG.error("FAILED to invoke getter for query param {} , is your param name correct?", qp.getName(), e);
        return false;
      }
    }
  return res;
}

代码示例来源:origin: hortonworks/registry

private List<OrderByField> getOrderByFields(List<QueryParam> queryParams) {
  if (queryParams == null || queryParams.isEmpty()) {
    return Collections.emptyList();
  }
  List<OrderByField> orderByFields = new ArrayList<>();
  for (QueryParam queryParam : queryParams) {
    if (ORDER_BY_FIELDS_PARAM_NAME.equals(queryParam.getName())) {
      // _orderByFields=[<field-name>,<a/d>,]*
      // example can be : _orderByFields=foo,a,bar,d
      // order by foo with ascending then bar with descending
      String value = queryParam.getValue();
      String[] splitStrings = value.split(",");
      for (int i = 0; i < splitStrings.length; i += 2) {
        String ascStr = splitStrings[i + 1];
        boolean descending;
        if ("a".equals(ascStr)) {
          descending = false;
        } else if ("d".equals(ascStr)) {
          descending = true;
        } else {
          throw new IllegalArgumentException("Ascending or Descending identifier can only be 'a' or 'd' respectively.");
        }
        orderByFields.add(OrderByField.of(splitStrings[i], descending));
      }
    }
  }
  return orderByFields;
}

代码示例来源:origin: hortonworks/streamline

private Collection<TopologyComponentBundle> listCustomProcessorBundlesWithFilter(List<QueryParam> params) throws IOException {
  List<QueryParam> queryParamsForTopologyComponent = new ArrayList<>();
  queryParamsForTopologyComponent.add(new QueryParam(TopologyComponentBundle.SUB_TYPE, TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_SUB_TYPE));
  for (QueryParam qp : params) {
    if (qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE)) {
      queryParamsForTopologyComponent.add(qp);
    }
  }
  Collection<TopologyComponentBundle> customProcessors = this.listTopologyComponentBundlesForTypeWithFilter(TopologyComponentBundle.TopologyComponentType
      .PROCESSOR, queryParamsForTopologyComponent);
  Collection<TopologyComponentBundle> result = new ArrayList<>();
  for (TopologyComponentBundle cp : customProcessors) {
    Map<String, Object> config = new HashMap<>();
    for (ComponentUISpecification.UIField uiField: cp.getTopologyComponentUISpecification().getFields()) {
      config.put(uiField.getFieldName(), uiField.getDefaultValue());
    }
    boolean matches = true;
    for (QueryParam qp : params) {
      if (!qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE) && !qp.getValue().equals(config.get(qp.getName()))) {
        matches = false;
        break;
      }
    }
    if (matches) {
      result.add(cp);
    }
  }
  return result;
}

代码示例来源:origin: hortonworks/registry

Columns columns = queryExecutor.getColumns(namespace);
for (QueryParam qp : queryParams) {
  Schema.Type type = columns.getType(qp.getName());
  if (type == null) {
    log.warn("Query parameter [{}] does not exist for namespace [{}]. Query parameter ignored.", qp.getName(), namespace);
  } else {
    fieldsToVal.put(new Schema.Field(qp.getName(), type),
        type.getJavaType().getConstructor(String.class).newInstance(qp.getValue()));

代码示例来源:origin: com.hortonworks.registries/storage-core

CaseAgnosticStringSet columnNames = queryExecutor.getColumnNames(namespace);
for (QueryParam qp : queryParams) {
  if (!columnNames.contains(qp.getName())) {
    log.warn("Query parameter [{}] does not exist for namespace [{}]. Query parameter ignored.", qp.getName(), namespace);
  } else {
    final String val = qp.getValue();
    final Schema.Type typeOfVal = Schema.Type.getTypeOfVal(val);
    fieldsToVal.put(new Schema.Field(qp.getName(), typeOfVal),
        typeOfVal.getJavaType().getConstructor(String.class).newInstance(val)); // instantiates object of the appropriate type

相关文章