本文整理汇总了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();
}
示例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!");
}
示例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);
}
}
示例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);
}
示例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);
}