當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。