當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。