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


Java FieldUtils.getFieldsListWithAnnotation方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.reflect.FieldUtils.getFieldsListWithAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java FieldUtils.getFieldsListWithAnnotation方法的具体用法?Java FieldUtils.getFieldsListWithAnnotation怎么用?Java FieldUtils.getFieldsListWithAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.reflect.FieldUtils的用法示例。


在下文中一共展示了FieldUtils.getFieldsListWithAnnotation方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClassParameters

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
private Map<String, String> getClassParameters() {
    final List<Field> fields = FieldUtils.getFieldsListWithAnnotation(getType(),
            ru.yandex.qatools.allure.annotations.Parameter.class);

    return fields.stream().collect(
            Collectors.toMap(Allure1Utils::getParameterName, f -> Allure1Utils.getParameterValue(f, target))
    );
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:9,代码来源:Allure1Annotations.java

示例2: getIdField

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
private Field getIdField(Class<?> domainClass) {
    Field idField = null;

    final List<Field> fields = FieldUtils.getFieldsListWithAnnotation(domainClass, Id.class);

    if (fields.isEmpty()) {
        idField = ReflectionUtils.findField(getJavaType(), "id");
    } else if (fields.size() == 1) {
        idField = fields.get(0);
    } else {
        throw new IllegalArgumentException("only one field with @Id annotation!");
    }

    if (idField != null && idField.getType() != String.class) {
        throw new IllegalArgumentException("type of id field must be String");
    }
    return idField;
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:19,代码来源:DocumentDbEntityInformation.java

示例3: getPartitionKeyField

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
private Field getPartitionKeyField(Class<?> domainClass) {
    Field partitionKeyField = null;

    final List<Field> fields = FieldUtils.getFieldsListWithAnnotation(domainClass, PartitionKey.class);

    if (fields.size() == 1) {
        partitionKeyField = fields.get(0);
    } else if (fields.size() > 1) {
        throw new IllegalArgumentException("Azure Cosmos DB supports only one partition key, " +
                "only one field with @PartitionKey annotation!");
    }

    if (partitionKeyField != null && partitionKeyField.getType() != String.class) {
        throw new IllegalArgumentException("type of PartitionKey field must be String");
    }
    return partitionKeyField;
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:18,代码来源:DocumentDbEntityInformation.java

示例4: injectContainers

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
private void injectContainers() {
  List<Field> fields = FieldUtils.getFieldsListWithAnnotation(testClass, InjectContainer.class);
  for (Field field : fields) {
    if (!Container.class.isAssignableFrom(field.getType())) {
      continue;
    }

    InjectContainer container = field.getAnnotation(InjectContainer.class);
    Container instance = controller.getContainer(container.name(), field.getType().asSubclass(Container.class));
    LOG.info("Binding [{}] -> [{}]", container.name(), instance.getName());
    try {
      FieldUtils.writeField(field, target, instance, true);
    } catch (IllegalAccessException e) {
      throw new IllegalStateException("Could not set field:" + field.getName());
    }
  }
}
 
开发者ID:Qorr,项目名称:Hvalspik,代码行数:18,代码来源:HvalspikRunner.java

示例5: inject

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
private void inject(Object mediator) {
  List<Field> list = FieldUtils.getFieldsListWithAnnotation(mediator.getClass(), Port.class);
  for (Field field : list) {
    Port annotation = field.getAnnotation(Port.class);
    if (field.getType().isAssignableFrom(Sink.class)) {
      Sink<Object> sink = getSinkOrFail(annotation.value());
      ReflectionHelper.set(mediator, field, sink);
    } else if (field.getType().isAssignableFrom(Source.class)) {
      Source<Object> source = getSourceOrFail(annotation.value());
      ReflectionHelper.set(mediator, field, source);
    }
  }
}
 
开发者ID:cescoffier,项目名称:fluid,代码行数:14,代码来源:Fluid.java

示例6: buildPropertyNameAndAliasMap

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
 * 提取 klass {@link Alias} 注释,将 属性名字和 {@link Alias#name()} 组成map 返回.
 *
 * @param klass
 *            the klass
 * @return 如果<code>klass</code> 没有 {@link Alias} 注释,返回 {@link Collections#emptyMap()}
 * @throws NullPointerException
 *             如果 <code>klass</code> 是null
 * @since 1.8.1
 */
private static Map<String, String> buildPropertyNameAndAliasMap(Class<?> klass){
    Validate.notNull(klass, "klass can't be null!");
    List<Field> aliasFieldsList = FieldUtils.getFieldsListWithAnnotation(klass, Alias.class);
    if (isNullOrEmpty(aliasFieldsList)){
        return emptyMap();
    }
    //属性名字和key的对应关系
    Map<String, String> propertyNameAndAliasMap = newHashMap(aliasFieldsList.size());
    for (Field field : aliasFieldsList){
        Alias alias = field.getAnnotation(Alias.class);
        propertyNameAndAliasMap.put(field.getName(), alias.name());
    }
    return propertyNameAndAliasMap;
}
 
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:25,代码来源:BeanUtil.java

示例7: deserializeFormFields

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
public static void deserializeFormFields(Object target, ValueMap input) throws DeserializeException {
    List<Field> fields = FieldUtils.getFieldsListWithAnnotation(target.getClass(), FormField.class);
    deserializeFields(target, fields, input);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:5,代码来源:AnnotatedFieldDeserializer.java

示例8: annotatedFields

import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
 * Get all fields of target instance annotated by given annotation type
 *
 * @param annotationClass type of annotation
 * @return annotated fields
 */
public List<Field> annotatedFields(Class<? extends Annotation> annotationClass) {
    return FieldUtils.getFieldsListWithAnnotation(clazz, annotationClass);
}
 
开发者ID:apiman,项目名称:apiman-test,代码行数:10,代码来源:AbstractAnnotationHandler.java


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