1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.repository;
20
21
22
23
24 public final class RepositoryPolicy {
25
26
27
28
29 public static final String UPDATE_POLICY_NEVER = "never";
30
31
32
33
34 public static final String UPDATE_POLICY_ALWAYS = "always";
35
36
37
38
39 public static final String UPDATE_POLICY_DAILY = "daily";
40
41
42
43
44 public static final String UPDATE_POLICY_INTERVAL = "interval";
45
46
47
48
49 public static final String CHECKSUM_POLICY_FAIL = "fail";
50
51
52
53
54 public static final String CHECKSUM_POLICY_WARN = "warn";
55
56
57
58
59 public static final String CHECKSUM_POLICY_IGNORE = "ignore";
60
61 private final boolean enabled;
62
63 private final String artifactUpdatePolicy;
64
65 private final String metadataUpdatePolicy;
66
67 private final String checksumPolicy;
68
69
70
71
72 public RepositoryPolicy() {
73 this(true, UPDATE_POLICY_DAILY, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN);
74 }
75
76
77
78
79
80 public RepositoryPolicy(boolean enabled, String updatePolicy, String checksumPolicy) {
81 this(enabled, updatePolicy, updatePolicy, checksumPolicy);
82 }
83
84
85
86
87
88
89
90
91
92
93
94
95 public RepositoryPolicy(
96 boolean enabled, String artifactUpdatePolicy, String metadataUpdatePolicy, String checksumPolicy) {
97 this.enabled = enabled;
98 this.artifactUpdatePolicy = (artifactUpdatePolicy != null) ? artifactUpdatePolicy : "";
99 this.metadataUpdatePolicy = (metadataUpdatePolicy != null) ? metadataUpdatePolicy : "";
100 this.checksumPolicy = (checksumPolicy != null) ? checksumPolicy : "";
101 }
102
103
104
105
106
107
108 public boolean isEnabled() {
109 return enabled;
110 }
111
112
113
114
115
116
117
118
119
120
121
122 @Deprecated
123 public String getUpdatePolicy() {
124 return getArtifactUpdatePolicy();
125 }
126
127
128
129
130
131
132
133 public String getArtifactUpdatePolicy() {
134 return artifactUpdatePolicy;
135 }
136
137
138
139
140
141
142
143 public String getMetadataUpdatePolicy() {
144 return metadataUpdatePolicy;
145 }
146
147
148
149
150
151
152 public String getChecksumPolicy() {
153 return checksumPolicy;
154 }
155
156 @Override
157 public String toString() {
158 return "enabled=" + isEnabled()
159 + ", checksums=" + getChecksumPolicy()
160 + ", artifactUpdates=" + getArtifactUpdatePolicy()
161 + ", metadataUpdates=" + getMetadataUpdatePolicy();
162 }
163
164 @Override
165 public boolean equals(Object obj) {
166 if (this == obj) {
167 return true;
168 }
169
170 if (obj == null || !getClass().equals(obj.getClass())) {
171 return false;
172 }
173
174 RepositoryPolicy that = (RepositoryPolicy) obj;
175
176 return enabled == that.enabled
177 && artifactUpdatePolicy.equals(that.artifactUpdatePolicy)
178 && metadataUpdatePolicy.equals(that.metadataUpdatePolicy)
179 && checksumPolicy.equals(that.checksumPolicy);
180 }
181
182 @Override
183 public int hashCode() {
184 int hash = 17;
185 hash = hash * 31 + (enabled ? 1 : 0);
186 hash = hash * 31 + artifactUpdatePolicy.hashCode();
187 hash = hash * 31 + metadataUpdatePolicy.hashCode();
188 hash = hash * 31 + checksumPolicy.hashCode();
189 return hash;
190 }
191 }