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 updatePolicy;
64
65 private final String checksumPolicy;
66
67
68
69
70 public RepositoryPolicy() {
71 this(true, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN);
72 }
73
74
75
76
77
78
79
80
81
82 public RepositoryPolicy(boolean enabled, String updatePolicy, String checksumPolicy) {
83 this.enabled = enabled;
84 this.updatePolicy = (updatePolicy != null) ? updatePolicy : "";
85 this.checksumPolicy = (checksumPolicy != null) ? checksumPolicy : "";
86 }
87
88
89
90
91
92
93 public boolean isEnabled() {
94 return enabled;
95 }
96
97
98
99
100
101
102 public String getUpdatePolicy() {
103 return updatePolicy;
104 }
105
106
107
108
109
110
111 public String getChecksumPolicy() {
112 return checksumPolicy;
113 }
114
115 @Override
116 public String toString() {
117 StringBuilder buffer = new StringBuilder(256);
118 buffer.append("enabled=").append(isEnabled());
119 buffer.append(", checksums=").append(getChecksumPolicy());
120 buffer.append(", updates=").append(getUpdatePolicy());
121 return buffer.toString();
122 }
123
124 @Override
125 public boolean equals(Object obj) {
126 if (this == obj) {
127 return true;
128 }
129
130 if (obj == null || !getClass().equals(obj.getClass())) {
131 return false;
132 }
133
134 RepositoryPolicy that = (RepositoryPolicy) obj;
135
136 return enabled == that.enabled
137 && updatePolicy.equals(that.updatePolicy)
138 && checksumPolicy.equals(that.checksumPolicy);
139 }
140
141 @Override
142 public int hashCode() {
143 int hash = 17;
144 hash = hash * 31 + (enabled ? 1 : 0);
145 hash = hash * 31 + updatePolicy.hashCode();
146 hash = hash * 31 + checksumPolicy.hashCode();
147 return hash;
148 }
149 }