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


Java Condition类代码示例

本文整理汇总了Java中org.springframework.context.annotation.Condition的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: allowStage

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
public boolean allowStage(Conditional[] conditionalClasses, ConditionalMatchType conditionalMatchType, Method method,
                          MongoParameterAccessor mongoParameterAccessor,
                          ConvertingParameterAccessor convertingParameterAccessor) {
  boolean shouldProcess = true;
  try {
    for (Conditional conditional : conditionalClasses) {
      List<Object> parameterValues = getParameterValues(method, mongoParameterAccessor, convertingParameterAccessor);
      ConditionalAnnotationMetadata metadata = new ConditionalAnnotationMetadata(conditional);
      AggregateQueryMethodConditionContext context = new AggregateQueryMethodConditionContext(method,
          parameterValues);
      Condition condition = conditional.condition().newInstance();
      boolean isTrue = condition.matches(context, metadata);
      if (conditionalMatchType == ConditionalMatchType.ANY && isTrue) {
        return true;
      }
      if(conditionalMatchType == ConditionalMatchType.ALL) {
        shouldProcess &= condition.matches(context, metadata);
      }
    }
  } catch (InstantiationException | IllegalAccessException e) {
    throw new IllegalStateException("Could not create an instance of the condition class", e);
  }
  return conditionalMatchType == ConditionalMatchType.ANY ? ArrayUtils.isEmpty(conditionalClasses) : shouldProcess;
}
 
开发者ID:krraghavan,项目名称:mongodb-aggregate-query-support,代码行数:25,代码来源:ProcessorUtils.java

示例2: setupAutoConfigurationReport

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
@PostConstruct
public void setupAutoConfigurationReport() {
	ConditionEvaluationReport report = ConditionEvaluationReport
			.get(this.context.getBeanFactory());
	report.recordConditionEvaluation("a", mock(Condition.class),
			mock(ConditionOutcome.class));
	report.recordExclusions(Arrays.asList("com.foo.Bar"));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:AutoConfigurationReportEndpointTests.java

示例3: matches

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
public static boolean matches(ConditionContext context) {
	Class<AuthorizationServerEndpointsConfigurationBeanCondition> type = AuthorizationServerEndpointsConfigurationBeanCondition.class;
	Conditional conditional = AnnotationUtils.findAnnotation(type,
			Conditional.class);
	StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(type);
	for (Class<? extends Condition> conditionType : conditional.value()) {
		Condition condition = BeanUtils.instantiateClass(conditionType);
		if (condition.matches(context, metadata)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:14,代码来源:OAuth2ResourceServerConfiguration.java

示例4: recordConditionEvaluation

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
/**
 * Record the occurrence of condition evaluation.
 * @param source the source of the condition (class or method name)
 * @param condition the condition evaluated
 * @param outcome the condition outcome
 */
public void recordConditionEvaluation(String source, Condition condition,
		ConditionOutcome outcome) {
	Assert.notNull(source, "Source must not be null");
	Assert.notNull(condition, "Condition must not be null");
	Assert.notNull(outcome, "Outcome must not be null");
	this.unconditionalClasses.remove(source);
	if (!this.outcomes.containsKey(source)) {
		this.outcomes.put(source, new ConditionAndOutcomes());
	}
	this.outcomes.get(source).add(condition, outcome);
	this.addedAncestorOutcomes = false;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:19,代码来源:ConditionEvaluationReport.java

示例5: getMemberConditions

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
private Map<AnnotationMetadata, List<Condition>> getMemberConditions(
		String[] members) {
	MultiValueMap<AnnotationMetadata, Condition> memberConditions = new LinkedMultiValueMap<AnnotationMetadata, Condition>();
	for (String member : members) {
		AnnotationMetadata metadata = getMetadata(member);
		for (String[] conditionClasses : getConditionClasses(metadata)) {
			for (String conditionClass : conditionClasses) {
				Condition condition = getCondition(conditionClass);
				memberConditions.add(metadata, condition);
			}
		}
	}
	return Collections.unmodifiableMap(memberConditions);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:15,代码来源:AbstractNestedCondition.java

示例6: getMatchOutcomes

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
public List<ConditionOutcome> getMatchOutcomes() {
	List<ConditionOutcome> outcomes = new ArrayList<ConditionOutcome>();
	for (Map.Entry<AnnotationMetadata, List<Condition>> entry : this.memberConditions
			.entrySet()) {
		AnnotationMetadata metadata = entry.getKey();
		List<Condition> conditions = entry.getValue();
		outcomes.add(new MemberOutcomes(this.context, metadata, conditions)
				.getUltimateOutcome());
	}
	return Collections.unmodifiableList(outcomes);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:12,代码来源:AbstractNestedCondition.java

示例7: MemberOutcomes

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
MemberOutcomes(ConditionContext context, AnnotationMetadata metadata,
		List<Condition> conditions) {
	this.context = context;
	this.metadata = metadata;
	this.outcomes = new ArrayList<ConditionOutcome>(conditions.size());
	for (Condition condition : conditions) {
		this.outcomes.add(getConditionOutcome(metadata, condition));
	}
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:10,代码来源:AbstractNestedCondition.java

示例8: getConditionOutcome

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
private ConditionOutcome getConditionOutcome(AnnotationMetadata metadata,
		Condition condition) {
	if (condition instanceof SpringBootCondition) {
		return ((SpringBootCondition) condition).getMatchOutcome(this.context,
				metadata);
	}
	return new ConditionOutcome(condition.matches(this.context, metadata),
			ConditionMessage.empty());
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:10,代码来源:AbstractNestedCondition.java

示例9: anyMatches

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
/**
 * Return true if any of the specified conditions match.
 * @param context the context
 * @param metadata the annotation meta-data
 * @param conditions conditions to test
 * @return {@code true} if any condition matches.
 */
protected final boolean anyMatches(ConditionContext context,
		AnnotatedTypeMetadata metadata, Condition... conditions) {
	for (Condition condition : conditions) {
		if (matches(context, metadata, condition)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:17,代码来源:SpringBootCondition.java

示例10: matches

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
/**
 * Return true if any of the specified condition matches.
 * @param context the context
 * @param metadata the annotation meta-data
 * @param condition condition to test
 * @return {@code true} if the condition matches.
 */
protected final boolean matches(ConditionContext context,
		AnnotatedTypeMetadata metadata, Condition condition) {
	if (condition instanceof SpringBootCondition) {
		return ((SpringBootCondition) condition).getMatchOutcome(context, metadata)
				.isMatch();
	}
	return condition.matches(context, metadata);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:16,代码来源:SpringBootCondition.java

示例11: MessageAndCondition

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
public MessageAndCondition(ConditionAndOutcome conditionAndOutcome) {
	Condition condition = conditionAndOutcome.getCondition();
	ConditionOutcome outcome = conditionAndOutcome.getOutcome();
	this.condition = ClassUtils.getShortName(condition.getClass());
	if (StringUtils.hasLength(outcome.getMessage())) {
		this.message = outcome.getMessage();
	}
	else {
		this.message = (outcome.isMatch() ? "matched" : "did not match");
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:AutoConfigurationReportEndpoint.java

示例12: getMatchOutcomes

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
public List<ConditionOutcome> getMatchOutcomes() {
	List<ConditionOutcome> outcomes = new ArrayList<ConditionOutcome>();
	for (Map.Entry<AnnotationMetadata, List<Condition>> entry : this.memberConditions
			.entrySet()) {
		AnnotationMetadata metadata = entry.getKey();
		for (Condition condition : entry.getValue()) {
			outcomes.add(getConditionOutcome(metadata, condition));
		}
	}
	return Collections.unmodifiableList(outcomes);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:AbstractNestedCondition.java

示例13: getConditionOutcome

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
private ConditionOutcome getConditionOutcome(AnnotationMetadata metadata,
		Condition condition) {
	String messagePrefix = "member condition on " + metadata.getClassName();
	if (condition instanceof SpringBootCondition) {
		ConditionOutcome outcome = ((SpringBootCondition) condition)
				.getMatchOutcome(this.context, metadata);
		String message = outcome.getMessage();
		return new ConditionOutcome(outcome.isMatch(), messagePrefix
				+ (StringUtils.hasLength(message) ? " : " + message : ""));
	}
	boolean matches = condition.matches(this.context, metadata);
	return new ConditionOutcome(matches, messagePrefix);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:AbstractNestedCondition.java

示例14: add

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
public void add(Condition condition, ConditionOutcome outcome) {
	this.outcomes.add(new ConditionAndOutcome(condition, outcome));
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:4,代码来源:ConditionEvaluationReport.java

示例15: ConditionAndOutcome

import org.springframework.context.annotation.Condition; //导入依赖的package包/类
public ConditionAndOutcome(Condition condition, ConditionOutcome outcome) {
	this.condition = condition;
	this.outcome = outcome;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:5,代码来源:ConditionEvaluationReport.java


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