Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PolicyStatus |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.retry; | |
8 | ||
9 | ||
10 | /** | |
11 | * Indicates the current state of a RetryPolicy | |
12 | * <ul> | |
13 | * <li>ok: The policy is active</li> | |
14 | * <li>exhausted: The policy has run through the actions for the policy</li> | |
15 | * </ul> | |
16 | * | |
17 | * For example, a RetryPolicy may have a RetryCount - how many times the policy can be invoked. | |
18 | * Once the retryCount has been reached, the policy is exhausted and cannot be used again. | |
19 | */ | |
20 | public class PolicyStatus | |
21 | { | |
22 | 0 | private boolean exhausted = false; |
23 | 0 | private boolean ok = false; |
24 | private Throwable throwable; | |
25 | ||
26 | public static PolicyStatus policyExhausted(Throwable t) | |
27 | { | |
28 | 0 | return new PolicyStatus(true, t); |
29 | } | |
30 | ||
31 | public static PolicyStatus policyOk() | |
32 | { | |
33 | 0 | return new PolicyStatus(); |
34 | } | |
35 | ||
36 | protected PolicyStatus() | |
37 | 0 | { |
38 | 0 | this.ok = true; |
39 | 0 | } |
40 | ||
41 | protected PolicyStatus(boolean exhausted, Throwable throwable) | |
42 | 0 | { |
43 | 0 | this.exhausted = exhausted; |
44 | 0 | this.throwable = throwable; |
45 | 0 | } |
46 | ||
47 | public boolean isExhausted() | |
48 | { | |
49 | 0 | return exhausted; |
50 | } | |
51 | ||
52 | public boolean isOk() | |
53 | { | |
54 | 0 | return ok; |
55 | } | |
56 | ||
57 | public Throwable getThrowable() | |
58 | { | |
59 | 0 | return throwable; |
60 | } | |
61 | } |