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


Java AnnotatedTypeMetadata.getAnnotationAttributes方法代码示例

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


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

示例1: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
	Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnPropertyPrefix.class.getName());
	if (attributes.containsKey("value")) {
		String prefix = (String) attributes.get("value");
		if (prefix != null && !prefix.trim().equals("")) {
			final String propertyPrefix = !prefix.endsWith(".") ? prefix + "." : prefix;
			ConfigPropertyProvider configPropertyProvider = EnvironmentConfigPropertyProvider
					.create(context.getEnvironment());
			Set<String> names = configPropertyProvider.getPropertyNames()
					.filter((n) -> n.startsWith(propertyPrefix)).collect(Collectors.toSet());
			if (!names.isEmpty()) {
				return ConditionOutcome.match();
			}
			return ConditionOutcome.noMatch(
					ConditionMessage.forCondition(ConditionalOnPropertyPrefix.class).notAvailable(propertyPrefix));
		}
	}
	return ConditionOutcome.match();
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:21,代码来源:OnPropertyPrefixCondition.java

示例2: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    if (!metadata.isAnnotated(ConditionalOnProperty.class.getName())) {
        return ConditionOutcome.match(StringUtils.EMPTY);
    }

    Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnProperty.class.getName());
    String key = attributes.get("key").toString();
    String value = attributes.get("value").toString();

    String realValue = Env.getString(key);

    if (!value.equals(realValue)) {
        return ConditionOutcome.noMatch(String.format("@ConditionalOnProperties's key:[%s], found value:[%s], not match given value:[%s]!", key, realValue, value));
    }

    return ConditionOutcome.match("@ConditionalOnProperties's key:[%s], found value:[%s], given value:[%s], matched!");
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:19,代码来源:OnPropertyCondition.java

示例3: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnOperatingSystem.class.getName());
    OperatingSystem operatingSystem = (OperatingSystem) attributes.get("value");
    ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnOperatingSystem.class);
    String name = operatingSystem.name();
    if (operatingSystem == OperatingSystem.WINDOWS && SystemInformation.INSTANCE.isWindows()) {
        return ConditionOutcome.match(message.foundExactly(name));
    }
    if (operatingSystem == OperatingSystem.UNIX && SystemInformation.INSTANCE.isUnix()) {
        return ConditionOutcome.match(message.foundExactly(name));
    }
    return ConditionOutcome.noMatch(message.didNotFind(name).atAll());
}
 
开发者ID:gavlyukovskiy,项目名称:azure-application-insights-spring-boot-starter,代码行数:15,代码来源:OnOperationSystemCondition.java

示例4: processRequestMappingAnnotation

import org.springframework.core.type.AnnotatedTypeMetadata; //导入方法依赖的package包/类
private void processRequestMappingAnnotation(AnnotatedTypeMetadata annotatedTypeMetadata, MethodMetadata.Builder requestTemplateBuilder) {
    Map<String, Object> requestMappingAttributes = annotatedTypeMetadata.getAnnotationAttributes(RequestMapping.class.getName());
    if (requestMappingAttributes != null && !requestMappingAttributes.isEmpty()) {
        parsePath(requestMappingAttributes, requestTemplateBuilder);
        parseMethod(requestMappingAttributes, requestTemplateBuilder);
        parseHeaders(requestMappingAttributes, requestTemplateBuilder);
        parseConsumes(requestMappingAttributes, requestTemplateBuilder);
        parseProduces(requestMappingAttributes, requestTemplateBuilder);
    }
}
 
开发者ID:jbrixhe,项目名称:spring-webflux-client,代码行数:11,代码来源:MethodMetadataFactory.java

示例5: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	Map<String, Object> attributes = metadata
			.getAnnotationAttributes(ConditionalOnJava.class.getName());
	Range range = (Range) attributes.get("range");
	JavaVersion version = (JavaVersion) attributes.get("value");
	return getMatchOutcome(range, JVM_VERSION, version);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:10,代码来源:OnJavaCondition.java

示例6: getParameterIndex

import org.springframework.core.type.AnnotatedTypeMetadata; //导入方法依赖的package包/类
protected int getParameterIndex(AnnotatedTypeMetadata annotatedTypeMetadata) {
  Map<String, Object> params = annotatedTypeMetadata.getAnnotationAttributes(Conditional.class.getName());
  return (int) params.get(ConditionalAnnotationMetadata.PARAMETER_INDEX);
}
 
开发者ID:krraghavan,项目名称:mongodb-aggregate-query-support,代码行数:5,代码来源:AbstractCondition.java


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