@@ -64,13 +64,6 @@ public abstract class AbstractVersionDetails implements VersionDetails {
64
64
*/
65
65
private ArtifactVersion currentVersion = null ;
66
66
67
- /**
68
- * Do we want to include snapshots when snapshot inclusion is not specified. Guarded by {@link #currentVersionLock}.
69
- *
70
- * @since 1.0-beta-1
71
- */
72
- private boolean includeSnapshots = false ;
73
-
74
67
protected boolean verboseDetail = true ;
75
68
76
69
/**
@@ -145,50 +138,18 @@ public final void setCurrentVersion(String currentVersion) {
145
138
setCurrentVersion (currentVersion == null ? null : new DefaultArtifactVersion (currentVersion ));
146
139
}
147
140
148
- @ Override
149
- public final boolean isIncludeSnapshots () {
150
- synchronized (currentVersionLock ) {
151
- return includeSnapshots ;
152
- }
153
- }
154
-
155
- @ Override
156
- public final void setIncludeSnapshots (boolean includeSnapshots ) {
157
- synchronized (currentVersionLock ) {
158
- this .includeSnapshots = includeSnapshots ;
159
- }
160
- }
161
-
162
- @ Override
163
- public final ArtifactVersion [] getVersions () {
164
- return getVersions (isIncludeSnapshots ());
165
- }
166
-
167
- @ Override
168
- public abstract ArtifactVersion [] getVersions (boolean includeSnapshots );
169
-
170
141
@ Override
171
142
public final ArtifactVersion [] getVersions (VersionRange versionRange , boolean includeSnapshots ) {
172
143
return getVersions (versionRange , null , includeSnapshots );
173
144
}
174
145
175
- @ Override
176
- public final ArtifactVersion [] getVersions (ArtifactVersion lowerBound , ArtifactVersion upperBound ) {
177
- return getVersions (lowerBound , upperBound , isIncludeSnapshots ());
178
- }
179
-
180
146
@ Override
181
147
public final ArtifactVersion [] getVersions (
182
148
ArtifactVersion lowerBound , ArtifactVersion upperBound , boolean includeSnapshots ) {
183
149
Restriction restriction = new Restriction (lowerBound , false , upperBound , false );
184
150
return getVersions (restriction , includeSnapshots );
185
151
}
186
152
187
- @ Override
188
- public final ArtifactVersion getNewestVersion (ArtifactVersion lowerBound , ArtifactVersion upperBound ) {
189
- return getNewestVersion (lowerBound , upperBound , isIncludeSnapshots ());
190
- }
191
-
192
153
@ Override
193
154
public final ArtifactVersion getNewestVersion (
194
155
ArtifactVersion lowerBound , ArtifactVersion upperBound , boolean includeSnapshots ) {
@@ -334,16 +295,6 @@ public final ArtifactVersion[] getAllUpdates(
334
295
}
335
296
}
336
297
337
- @ Override
338
- public final ArtifactVersion getNewestUpdate (Optional <Segment > updateScope ) {
339
- return getNewestUpdate (updateScope , isIncludeSnapshots ());
340
- }
341
-
342
- @ Override
343
- public final ArtifactVersion [] getAllUpdates (Optional <Segment > updateScope ) {
344
- return getAllUpdates (updateScope , isIncludeSnapshots ());
345
- }
346
-
347
298
@ Override
348
299
public final ArtifactVersion getNewestUpdate (Optional <Segment > updateScope , boolean includeSnapshots ) {
349
300
if (isCurrentVersionDefined ()) {
@@ -361,13 +312,8 @@ public final ArtifactVersion[] getAllUpdates(Optional<Segment> updateScope, bool
361
312
}
362
313
363
314
@ Override
364
- public final ArtifactVersion [] getAllUpdates () {
365
- return getAllUpdates ((VersionRange ) null , isIncludeSnapshots ());
366
- }
367
-
368
- @ Override
369
- public final ArtifactVersion [] getAllUpdates (VersionRange versionRange ) {
370
- return getAllUpdates (versionRange , isIncludeSnapshots ());
315
+ public final ArtifactVersion [] getAllUpdates (boolean includeSnapshots ) {
316
+ return getAllUpdates ((VersionRange ) null , includeSnapshots );
371
317
}
372
318
373
319
@ Override
@@ -441,24 +387,26 @@ public boolean isVersionInRestriction(Restriction restriction, ArtifactVersion c
441
387
442
388
/**
443
389
* Returns the latest version newer than the specified current version, and within the specified update scope,
444
- * or < code> null</code> if no such version exists.
390
+ * or {@ code null} if no such version exists.
445
391
* @param updateScope the scope of updates to include.
392
+ * @param includeSnapshots whether snapshots should be included
446
393
* @return the newest version after currentVersion within the specified update scope,
447
394
* or <code>null</code> if no version is available.
448
395
*/
449
- public final ArtifactVersion getReportNewestUpdate (Optional <Segment > updateScope ) {
450
- return getArtifactVersionStream (updateScope )
396
+ public final ArtifactVersion getReportNewestUpdate (Optional <Segment > updateScope , boolean includeSnapshots ) {
397
+ return getArtifactVersionStream (updateScope , includeSnapshots )
451
398
.min (Collections .reverseOrder (getVersionComparator ()))
452
399
.orElse (null );
453
400
}
454
401
455
402
/**
456
403
* Returns all versions newer than the specified current version, and within the specified update scope.
457
404
* @param updateScope the scope of updates to include.
405
+ * @param includeSnapshots whether snapshots should be included
458
406
* @return all versions after currentVersion within the specified update scope.
459
407
*/
460
- public final ArtifactVersion [] getReportUpdates (Optional <Segment > updateScope ) {
461
- TreeSet <ArtifactVersion > versions = getArtifactVersionStream (updateScope )
408
+ public final ArtifactVersion [] getReportUpdates (Optional <Segment > updateScope , boolean includeSnapshots ) {
409
+ TreeSet <ArtifactVersion > versions = getArtifactVersionStream (updateScope , includeSnapshots )
462
410
.collect (Collectors .toCollection (() -> new TreeSet <>(getVersionComparator ())));
463
411
// filter out intermediate minor versions.
464
412
if (!verboseDetail ) {
@@ -493,16 +441,16 @@ public final ArtifactVersion[] getReportUpdates(Optional<Segment> updateScope) {
493
441
/**
494
442
* Returns all versions newer than the specified current version, and within the specified update scope.
495
443
* @param updateScope the scope of updates to include.
444
+ * @param includeSnapshots whether snapshots should be included
496
445
* @return all versions after currentVersion within the specified update scope.
497
446
*/
498
- private Stream <ArtifactVersion > getArtifactVersionStream (Optional <Segment > updateScope ) {
447
+ private Stream <ArtifactVersion > getArtifactVersionStream (Optional <Segment > updateScope , boolean includeSnapshots ) {
499
448
if (isCurrentVersionDefined ()) {
500
449
try {
501
450
Restriction restriction = restrictionFor (updateScope );
502
451
503
- return Arrays .stream (getVersions ())
504
- .filter (candidate -> (isIncludeSnapshots () || !ArtifactUtils .isSnapshot (candidate .toString ()))
505
- && isVersionInRestriction (restriction , candidate ));
452
+ return Arrays .stream (getVersions (includeSnapshots ))
453
+ .filter (candidate -> isVersionInRestriction (restriction , candidate ));
506
454
} catch (InvalidSegmentException ignored ) {
507
455
ignored .printStackTrace (System .err );
508
456
}
0 commit comments