List of usage examples for org.apache.commons.lang BooleanUtils toBooleanDefaultIfNull
public static boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull)
Converts a Boolean to a boolean handling null
.
BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false) = true BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true) = false BooleanUtils.toBooleanDefaultIfNull(null, true) = true
From source file:org.springframework.cloud.netflix.ribbon.okhttp.RetryableOkHttpLoadBalancingClient.java
private OkHttpRibbonResponse executeWithRetry(OkHttpRibbonRequest request, LoadBalancedRetryPolicy retryPolicy, RetryCallback<OkHttpRibbonResponse, Exception> callback) throws Exception { RetryTemplate retryTemplate = new RetryTemplate(); boolean retryable = request.getContext() == null ? true : BooleanUtils.toBooleanDefaultIfNull(request.getContext().getRetryable(), true); retryTemplate.setRetryPolicy(retryPolicy == null || !retryable ? new NeverRetryPolicy() : new RetryPolicy(request, retryPolicy, this, this.getClientName())); return retryTemplate.execute(callback); }
From source file:org.springframework.cloud.netflix.ribbon.support.RetryableLoadBalancingClient.java
/** * Executes a {@link S} using Spring Retry. * @param request The request to execute. * @param callback The retry callback to use. * @return The response.//from www . j a va 2 s. c o m * @throws Exception Thrown if there is an error making the request and a retry cannot be completed successfully. */ protected T executeWithRetry(S request, RetryCallback<T, IOException> callback) throws Exception { LoadBalancedRetryPolicy retryPolicy = loadBalancedRetryPolicyFactory.create(this.getClientName(), this); RetryTemplate retryTemplate = new RetryTemplate(); boolean retryable = request.getContext() == null ? true : BooleanUtils.toBooleanDefaultIfNull(request.getContext().getRetryable(), true); retryTemplate.setRetryPolicy(retryPolicy == null || !retryable ? new NeverRetryPolicy() : new RetryPolicy(request, retryPolicy, this, this.getClientName())); return retryTemplate.execute(callback); }
From source file:org.tap4j.plugin.TapPublisher.java
@DataBoundConstructor public TapPublisher(String testResults, Boolean failIfNoResults, Boolean failedTestsMarkBuildAsFailure, Boolean outputTapToConsole, Boolean enableSubtests, Boolean discardOldReports, Boolean todoIsFailure, Boolean includeCommentDiagnostics, Boolean validateNumberOfTests, Boolean planRequired, Boolean verbose, Boolean showOnlyFailures) { this.testResults = testResults; this.failIfNoResults = BooleanUtils.toBooleanDefaultIfNull(failIfNoResults, false); this.failedTestsMarkBuildAsFailure = BooleanUtils.toBooleanDefaultIfNull(failedTestsMarkBuildAsFailure, false);/*from ww w .j a v a2s.c om*/ this.outputTapToConsole = outputTapToConsole; this.enableSubtests = BooleanUtils.toBooleanDefaultIfNull(enableSubtests, true); this.discardOldReports = BooleanUtils.toBooleanDefaultIfNull(discardOldReports, false); this.todoIsFailure = BooleanUtils.toBooleanDefaultIfNull(todoIsFailure, true); this.includeCommentDiagnostics = BooleanUtils.toBooleanDefaultIfNull(includeCommentDiagnostics, true); this.validateNumberOfTests = BooleanUtils.toBooleanDefaultIfNull(validateNumberOfTests, false); this.planRequired = BooleanUtils.toBooleanDefaultIfNull(planRequired, true); // true is the old behaviour this.verbose = BooleanUtils.toBooleanDefaultIfNull(verbose, true); this.showOnlyFailures = BooleanUtils.toBooleanDefaultIfNull(showOnlyFailures, false); }
From source file:org.tap4j.plugin.TapPublisher.java
public Object readResolve() { String testResults = this.getTestResults(); Boolean failIfNoResults = BooleanUtils.toBooleanDefaultIfNull(this.getFailIfNoResults(), false); Boolean failedTestsMarkBuildAsFailure = BooleanUtils .toBooleanDefaultIfNull(this.getFailedTestsMarkBuildAsFailure(), false); Boolean outputTapToConsole = BooleanUtils.toBooleanDefaultIfNull(this.getOutputTapToConsole(), false); Boolean enableSubtests = BooleanUtils.toBooleanDefaultIfNull(this.getEnableSubtests(), true); Boolean discardOldReports = BooleanUtils.toBooleanDefaultIfNull(this.getDiscardOldReports(), false); Boolean todoIsFailure = BooleanUtils.toBooleanDefaultIfNull(this.getTodoIsFailure(), true); Boolean includeCommentDiagnostics = BooleanUtils.toBooleanDefaultIfNull(this.getIncludeCommentDiagnostics(), true);/*from w ww. j a v a 2s . co m*/ Boolean validateNumberOfTests = BooleanUtils.toBooleanDefaultIfNull(this.getValidateNumberOfTests(), false); Boolean planRequired = BooleanUtils.toBooleanDefaultIfNull(this.getPlanRequired(), true); Boolean verbose = BooleanUtils.toBooleanDefaultIfNull(this.getVerbose(), true); Boolean showOnlyFailures = BooleanUtils.toBooleanDefaultIfNull(this.getShowOnlyFailures(), false); return new TapPublisher(testResults, failIfNoResults, failedTestsMarkBuildAsFailure, outputTapToConsole, enableSubtests, discardOldReports, todoIsFailure, includeCommentDiagnostics, validateNumberOfTests, planRequired, verbose, showOnlyFailures); }
From source file:org.tap4j.plugin.TapResult.java
public Boolean getShowOnlyFailures() { return BooleanUtils.toBooleanDefaultIfNull(showOnlyFailures, Boolean.FALSE); }