GenericConfig.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:wildfly-swarm 作者:
/**
 * Note that:
 *
 * <pre>
 * If no annotation matches the specified parameter, the property will be ignored.
 * </pre>
 *
 * @param key
 * @param expectedType
 * @return the configured value
 */
private <U> U lookup(String key, Class<U> expectedType) {
    Config config = getConfig();
    Optional<U> value = null;
    if (ElementType.METHOD.equals(annotationSource)) {
        // <classname>/<methodname>/<annotation>/<parameter>
        value = config.getOptionalValue(getConfigKeyForMethod() + key, expectedType);
    } else {
        // <classname>/<annotation>/<parameter>
        value = config.getOptionalValue(getConfigKeyForClass() + key, expectedType);
    }
    if (!value.isPresent()) {
        // <annotation>/<parameter>
        value = config.getOptionalValue(getConfigType().getSimpleName() + "/" + key, expectedType);
    }
    // annotation values
    return value.isPresent() ? value.get() : getConfigFromAnnotation(key);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号