當前位置: 首頁>>代碼示例>>Java>>正文


Java ReflectionUtils.getFields方法代碼示例

本文整理匯總了Java中org.reflections.ReflectionUtils.getFields方法的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionUtils.getFields方法的具體用法?Java ReflectionUtils.getFields怎麽用?Java ReflectionUtils.getFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.reflections.ReflectionUtils的用法示例。


在下文中一共展示了ReflectionUtils.getFields方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPluginConfigAndDisplayMap

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
/**
 * Gets the config and display map. Display map is a mapping from field name to how the field
 * should be displayed in the UI
 * @param remoteType The remote type that identifies what plugin to get
 * @return
 * @throws IOException
 */
@SuppressWarnings({ "unchecked" })
@RequestMapping(method = { RequestMethod.GET }, value = "/plugins/remote/cdm/{remoteType}")
@ResponseBody
public Map<String, Object> getPluginConfigAndDisplayMap(@PathVariable String remoteType) throws IOException {
    PluginConfiguration config = getRemotePlugin(remoteType);
    if (config == null) return null;
    Map<String, String> displayMap = new HashMap<String, String>();
    Set<Field> fields = ReflectionUtils.getFields(config.getClass(), ReflectionUtils.withAnnotation(PluginConfigValue.class));
    for (Field field : fields) {
        String disp = field.getAnnotation(PluginConfigValue.class).display();
        if (StringUtils.isEmpty(disp)) {
            disp = field.getName();
        }
        displayMap.put(field.getName(), disp);
    }
    Map<String, Object> configAndDM = new HashMap<>();
    configAndDM.put("config", config);
    configAndDM.put("displayMap", displayMap);
    return configAndDM;
}
 
開發者ID:Comcast,項目名稱:dawg,代碼行數:28,代碼來源:PluginController.java

示例2: getEventStreamId

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
public String getEventStreamId() {
    Set<Field> fields =
            ReflectionUtils.getFields(getClass(),
                    ReflectionUtils.withAnnotation(EventStreamId.class));

    if (fields.size() != 1) {
        throw new RuntimeException(
                String.format("No aggregate id field found in class %s", getClass()));
    }

    Field first = fields.iterator().next();
    first.setAccessible(true);

    try {
        return (String) first.get(this);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:indifferen7,項目名稱:casual-eventsourcing,代碼行數:20,代碼來源:Aggregate.java

示例3: setEventStreamId

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
private void setEventStreamId(T aggregate, String id) {
    Set<Field> fields =
            ReflectionUtils.getFields(getAggregateClass(),
                    ReflectionUtils.withAnnotation(EventStreamId.class));

    if (fields.size() != 1) {
        throw new RuntimeException(
                String.format("No aggregate id field found in class %s", getAggregateClass()));
    }

    Field first = fields.iterator().next();

    try {
        first.setAccessible(true);
        first.set(aggregate, id);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(
                String.format("Could not set aggregate id on class %s", getAggregateClass()));
    }
}
 
開發者ID:indifferen7,項目名稱:casual-eventsourcing,代碼行數:21,代碼來源:AggregateRepository.java


注:本文中的org.reflections.ReflectionUtils.getFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。