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