Package io.github.qishr.cascara.common.semver
Class Requirement
java.lang.Object
io.github.qishr.cascara.common.semver.Requirement
public class Requirement
A requirement will provide an easy way to check if a version is satisfying.There are 2 types of requirements: - Strict: checks if a version is equivalent to another - NPM: follows the rules of NPM
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
| protected final RequirementOperator | op | |
| protected final Range | range | |
| protected final Requirement | req1 | |
| protected final Requirement | req2 |
Constructor Summary
| Constructor | Description |
|---|---|
| Requirement(Range range, Requirement req1, RequirementOperator op, Requirement req2) | Builds a requirement. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public static Requirement | build(SemVer requirement) | Builds a requirement (will test that the version is equivalent to the requirement) |
| public static Requirement | buildStrict(String requirement) | Builds a strict requirement (will test that the version is equivalent to the requirement) |
| public static Requirement | buildLoose(String requirement) | Builds a loose requirement (will test that the version is equivalent to the requirement) |
| public static Requirement | buildNPM(String requirement) | Builds a requirement following the rules of NPM. |
| public static Requirement | buildCocoapods(String requirement) | Builds a requirement following the rules of Cocoapods. |
| public static Requirement | buildIvy(String requirement) | Builds a requirement following the rules of Ivy. |
| protected static Requirement | tildeRequirement(String version, SemVerType type) | Allows patch-level changes if a minor version is specified on the comparator. |
| protected static Requirement | caretRequirement(String version, SemVerType type) | Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple. |
| protected static Requirement | hyphenRequirement(String lowerVersion, String upperVersion, SemVerType type) | Creates a requirement that satisfies "x1.y1.z1 - x2.y2.z2". |
| public boolean | isSatisfiedBy(String version) | |
| public boolean | isSatisfiedBy(SemVer version) | Checks if the requirement is satisfied by a version. |
| public boolean | equals(Object o) | |
| public int | hashCode() | |
| public String | toString() |
Field Details
op
protected final RequirementOperator op
range
protected final Range range
req1
protected final Requirement req1
req2
protected final Requirement req2
Method Details
build
public static Requirement build(SemVer requirement)
Builds a requirement (will test that the version is equivalent to the requirement)
Parameters:
requirement - the version of the requirement
Returns:
the generated requirement
buildStrict
public static Requirement buildStrict(String requirement)
Builds a strict requirement (will test that the version is equivalent to the requirement)
Parameters:
requirement - the version of the requirement
Returns:
the generated requirement
buildLoose
public static Requirement buildLoose(String requirement)
Builds a loose requirement (will test that the version is equivalent to the requirement)
Parameters:
requirement - the version of the requirement
Returns:
the generated requirement
buildNPM
public static Requirement buildNPM(String requirement)
Builds a requirement following the rules of NPM.
Parameters:
requirement - the requirement as a string
Returns:
the generated requirement
buildCocoapods
public static Requirement buildCocoapods(String requirement)
Builds a requirement following the rules of Cocoapods.
Parameters:
requirement - the requirement as a string
Returns:
the generated requirement
buildIvy
public static Requirement buildIvy(String requirement)
Builds a requirement following the rules of Ivy.
Parameters:
requirement - the requirement as a string
Returns:
the generated requirement
tildeRequirement
protected static Requirement tildeRequirement(String version, SemVerType type)
Allows patch-level changes if a minor version is specified on the comparator.Allows minor-level changes if not.
Parameters:
version - the version of the requirement
type - the version system used for this requirement
Returns:
the generated requirement
caretRequirement
protected static Requirement caretRequirement(String version, SemVerType type)
Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple.
Parameters:
version - the version of the requirement
type - the version system used for this requirement
Returns:
the generated requirement
hyphenRequirement
protected static Requirement hyphenRequirement(String lowerVersion, String upperVersion, SemVerType type)
Creates a requirement that satisfies "x1.y1.z1 - x2.y2.z2".
Parameters:
lowerVersion - the version of the lower bound of the requirement
upperVersion - the version of the upper bound of the requirement
type - the version system used for this requirement
Returns:
the generated requirement
isSatisfiedBy
public boolean isSatisfiedBy(String version)
Parameters:
version - the version that will be checked
Returns:
true if the version satisfies the requirement
See Also:
isSatisfiedBy
public boolean isSatisfiedBy(SemVer version)
Checks if the requirement is satisfied by a version.
Parameters:
version - the version that will be checked
Returns:
true if the version satisfies the requirement
equals
public boolean equals(Object o)
hashCode
public int hashCode()
toString
public String toString()