@@ -64,13 +64,6 @@ public abstract class AbstractVersionDetails implements VersionDetails {
6464 */
6565 private ArtifactVersion currentVersion = null ;
6666
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-
7467 protected boolean verboseDetail = true ;
7568
7669 /**
@@ -145,50 +138,18 @@ public final void setCurrentVersion(String currentVersion) {
145138 setCurrentVersion (currentVersion == null ? null : new DefaultArtifactVersion (currentVersion ));
146139 }
147140
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-
170141 @ Override
171142 public final ArtifactVersion [] getVersions (VersionRange versionRange , boolean includeSnapshots ) {
172143 return getVersions (versionRange , null , includeSnapshots );
173144 }
174145
175- @ Override
176- public final ArtifactVersion [] getVersions (ArtifactVersion lowerBound , ArtifactVersion upperBound ) {
177- return getVersions (lowerBound , upperBound , isIncludeSnapshots ());
178- }
179-
180146 @ Override
181147 public final ArtifactVersion [] getVersions (
182148 ArtifactVersion lowerBound , ArtifactVersion upperBound , boolean includeSnapshots ) {
183149 Restriction restriction = new Restriction (lowerBound , false , upperBound , false );
184150 return getVersions (restriction , includeSnapshots );
185151 }
186152
187- @ Override
188- public final ArtifactVersion getNewestVersion (ArtifactVersion lowerBound , ArtifactVersion upperBound ) {
189- return getNewestVersion (lowerBound , upperBound , isIncludeSnapshots ());
190- }
191-
192153 @ Override
193154 public final ArtifactVersion getNewestVersion (
194155 ArtifactVersion lowerBound , ArtifactVersion upperBound , boolean includeSnapshots ) {
@@ -334,16 +295,6 @@ public final ArtifactVersion[] getAllUpdates(
334295 }
335296 }
336297
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-
347298 @ Override
348299 public final ArtifactVersion getNewestUpdate (Optional <Segment > updateScope , boolean includeSnapshots ) {
349300 if (isCurrentVersionDefined ()) {
@@ -361,13 +312,8 @@ public final ArtifactVersion[] getAllUpdates(Optional<Segment> updateScope, bool
361312 }
362313
363314 @ 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 );
371317 }
372318
373319 @ Override
@@ -441,24 +387,26 @@ public boolean isVersionInRestriction(Restriction restriction, ArtifactVersion c
441387
442388 /**
443389 * 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.
445391 * @param updateScope the scope of updates to include.
392+ * @param includeSnapshots whether snapshots should be included
446393 * @return the newest version after currentVersion within the specified update scope,
447394 * or <code>null</code> if no version is available.
448395 */
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 )
451398 .min (Collections .reverseOrder (getVersionComparator ()))
452399 .orElse (null );
453400 }
454401
455402 /**
456403 * Returns all versions newer than the specified current version, and within the specified update scope.
457404 * @param updateScope the scope of updates to include.
405+ * @param includeSnapshots whether snapshots should be included
458406 * @return all versions after currentVersion within the specified update scope.
459407 */
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 )
462410 .collect (Collectors .toCollection (() -> new TreeSet <>(getVersionComparator ())));
463411 // filter out intermediate minor versions.
464412 if (!verboseDetail ) {
@@ -493,16 +441,16 @@ public final ArtifactVersion[] getReportUpdates(Optional<Segment> updateScope) {
493441 /**
494442 * Returns all versions newer than the specified current version, and within the specified update scope.
495443 * @param updateScope the scope of updates to include.
444+ * @param includeSnapshots whether snapshots should be included
496445 * @return all versions after currentVersion within the specified update scope.
497446 */
498- private Stream <ArtifactVersion > getArtifactVersionStream (Optional <Segment > updateScope ) {
447+ private Stream <ArtifactVersion > getArtifactVersionStream (Optional <Segment > updateScope , boolean includeSnapshots ) {
499448 if (isCurrentVersionDefined ()) {
500449 try {
501450 Restriction restriction = restrictionFor (updateScope );
502451
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 ));
506454 } catch (InvalidSegmentException ignored ) {
507455 ignored .printStackTrace (System .err );
508456 }
0 commit comments