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