Depend
@Serializable { simple=true }
const class Depend : Obj
Depend models a dependency as a pod name and a version constraint. Convention for Fantom pods is a four part version format of major.minor.build.patch.
The string format for Depend:
<depend> := <name> space* <constraints> <constraints> := <constraint> [space* "," space* <constraint>]* <constraint> := <versionSimple> | <versionPlus> | <versionRange> <versionSimple> := <version> <versionPlus> := <version> space* "+" <versionRange> := <version> space* "-" space* <version> <version> := <digits> ["." <digits>]* <digits> := <digit> [<digits>]* <digit> := "0" - "9"
Note a simple version constraint such as "foo 1.2" really means "1.2.*" - it will match all build numbers and patch numbers within "1.2". Likewise "foo 1.2.64" will match all patch numbers within the "1.2.64" build. The "+" plus sign is used to specify a given version and anything greater. The "-" dash is used to specify an inclusive range. When using a range, the end version is matched using the same rules as a simple version - for example "4", "4.2", and "4.0.99" are all matches for "foo 1.2-4". You may specify a list of potential constraints separated by commas - a match for the entire dependency is made if any one constraint is matched.
Examples:
"foo 1.2" Any version of foo 1.2 with any build or patch number "foo 1.2.64" Any version of foo 1.2.64 with any patch number "foo 0+" Any version of foo - version wildcard "foo 1.2+" Any version of foo 1.2 or greater "foo 1.2-1.4" Any version between 1.2 and 1.4 inclusive "foo 1.2,1.4" Any version of 1.2 or 1.4
Parse the string accordingly into a dependency
Get the normalized string format of this dependency
Return if the constraint at the specified index is a versionPlus
Get the number of version constraints
Two Depends are equal if they have same normalized string representation
Return if the specified version is a match against this dependency's constraints
Get the pod name of the dependency
Return the ending version if versionRange
Return if the constraint at the specified index is neither a plus nor a range
Get the version constraint at specified index
Return a hash code based on the normalized string representation
Return if the constraint at the specified index is a versionRange
Version endVersion(Int index)
Return the ending version if versionRange:
- versionSimple: returns null
- versionPlus: returns null
- versionRange: returns end version
virtual Bool equals(Obj? that)
Two Depends are equal if they have same normalized string representation.
static new fromStr(Str s, Bool checked)
Parse the string accordingly into a dependency. See class header for specification of the format. If invalid format and checked is false return null, otherwise throw ParseErr.
virtual Int hash()
Return a hash code based on the normalized string representation.
Bool isPlus(Int index)
Return if the constraint at the specified index is a versionPlus:
- versionSimple: returns false
- versionPlus: returns true
- versionRange: returns false
Bool isRange(Int index)
Return if the constraint at the specified index is a versionRange:
- versionSimple: returns false
- versionPlus: returns false
- versionRange: returns true
Bool isSimple(Int index)
Return if the constraint at the specified index is neither a plus nor a range:
- versionSimple: returns true
- versionPlus: returns false
- versionRange: returns false
Bool match(Version version)
Return if the specified version is a match against this dependency's constraints. See class header for matching rules.
Str name()
Get the pod name of the dependency.
Int size()
Get the number of version constraints. There is always at least one constraint.
virtual Str toStr()
Get the normalized string format of this dependency. Normalized dependency strings do not contain any optional spaces. See class header for specification of the format.
Version version(Int index)
Get the version constraint at specified index:
- versionSimple: returns the version
- versionPlus: returns the version
- versionRange: returns the start version