Package org.stianloader.picoresolve.version

# Enum Class VersionSelectionPreference

java.lang.Object
java.lang.Enum<VersionSelectionPreference>
org.stianloader.picoresolve.version.VersionSelectionPreference

All Implemented Interfaces:
  `Serializable`, `Comparable<VersionSelectionPreference>`, `Constable`

@AvailableSince("1.1.0-a20260531") public enum VersionSelectionPreference extends Enum<VersionSelectionPreference>
When selecting between multiple requested versions, it is imperative to have a defined order which requested version is being ultimately used.

More specifically, when having a version `V0` declared by artifact `A0` and a version `V1` declared by artifact `A1`, it is important to know whether version `V0` or version `V1` is being used.

For this metric, there are two comparison methods available:

- Compare using the version itself, ignoring the declaring artifact. This corresponds to `NEWEST_FIRST`.
- Alternatively, compare using the declaring artifact. In the case of `DECLARATION_ORDER` it uses the declaration order as the baseline metric. As such, the version order can be ignored.

Since:
  1.1.0-a20260531

## Nested Class Summary

## Nested classes/interfaces inherited from class java.lang.Enum

`Enum.EnumDesc<E extends Enum<E>>`

## Enum Constant Summary

Enum Constants
Enum Constant
Description
`DECLARATION_ORDER`
Prefer versions defined by artifacts that have been declared first in the POM.
`NEWEST_FIRST`
Prefer versions that are newer on their own, as per `MavenVersion.isNewerThan(MavenVersion)`.

## Method Summary

Modifier and Type
Method
Description
`static VersionSelectionPreference`
`valueOf(String name)`
Returns the enum constant of this class with the specified name.
`static VersionSelectionPreference[]`
`values()`
Returns an array containing the constants of this enum class, in the order they are declared.

### Methods inherited from class java.lang.Enum

`clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

## Enum Constant Details

### DECLARATION_ORDER

@AvailableSince("1.1.0-a20260531") public static final VersionSelectionPreference DECLARATION_ORDER
Prefer versions defined by artifacts that have been declared first in the POM.

As picoresolve is a concurrent environment, this declaration order might be dependent on the `Executor` being used, as well as pure chance. However, such randomness is usually indicative of a bug within picoresolve. Please report such issues whenever they arise.

This is the metric being used in Maven's artifact resolver, as well as the default metric in picoresolve since version `1.1.0-a20260531`.

In practice, the artifact declaration order is defined using the order in which `VersionRange` instances are intersected with each other, i.e. the order of the `VersionRange.intersect(VersionRange)` calls.

Since:
  1.1.0-a20260531

### NEWEST_FIRST

@AvailableSince("1.1.0-a20260531") public static final VersionSelectionPreference NEWEST_FIRST
Prefer versions that are newer on their own, as per `MavenVersion.isNewerThan(MavenVersion)`.

This is the most stable metric in a concurrent environment, as it does not depend on the order in which tasks are completed. It bypasses minor bugs concerning collections that have no defined order, such as `HashMap`.

Further, this metric is rather intuitive with picoresolve's "resolve in layer" model, even though the artifact ordering semantics are indirectly exposed due to `DependencyLayer.elements` being a `List`.

This was the only metric used in picoresolve before version `1.1.0-a20260531`. However, it is no longer the default as the maven artifact resolve does not make use of that metric.

Since:
  1.1.0-a20260531

## Method Details

### values

public static VersionSelectionPreference[] values()
Returns an array containing the constants of this enum class, in the order they are declared.

Returns:
  an array containing the constants of this enum class, in the order they are declared

### valueOf

public static VersionSelectionPreference valueOf(String name)
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)

Parameters:
  `name` - the name of the enum constant to be returned.
Returns:
  the enum constant with the specified name
Throws:
  `IllegalArgumentException` - if this enum class has no constant with the specified name
  `NullPointerException` - if the argument is null