Skip to content
This repository has been archived by the owner on Oct 10, 2021. It is now read-only.

Commit

Permalink
Finish documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
NthPortal committed Jan 20, 2017
1 parent ea0ac25 commit 70f368d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ abstract class ExtendedVersionCompanion[V <: VersionBase[V, EV], EV[E] <: Extend
/**
* Parses a string into an extended version.
*
* @param v the string to parse
* @param v the string to parse
* @param ed the [[ExtensionDef extension definition]]
* @param ep a [[ExtensionParser parser]] for extensions
* @tparam E the type of the extension
* @throws VersionFormatException if the given string is not a valid extended version
* @return the extended version represented by the string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,25 @@ package compat

import scala.language.higherKinds

/**
* Base class for (extended) version factories.
*
* @param extensionDef the [[ExtensionDef extension definition]]
* @param parser a [[ExtensionParser parser]] for extensions
* @param companion a companion for the extended version
* @tparam V the type of the version component of the extended version
* @tparam E the type of the extension component of the extended version
* @tparam EV the type of the extended version
*/
private[versions]
abstract class VersionFactoryBase[V <: VersionBase[V, EV], E, EV[X] <: ExtendedVersionBase[V, X, EV]]
(extensionDef: ExtensionDef[E], parser: ExtensionParser[E], companion: ExtendedVersionCompanion[V, EV]) {
/**
* Parses a string into an extended version.
*
* @param v the string to parse
* @throws VersionFormatException if the given string is not a valid extended version
* @return the extended version represented by the string
*/
def parseVersion(v: String): EV[E] = companion.parseVersion(v)(extensionDef, parser)
}
26 changes: 26 additions & 0 deletions src/main/scala/com/nthportal/versions/extensions/Maven.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
package com.nthportal.versions
package extensions

/**
* A simple [[https://maven.apache.org/ Maven]] version extension,
* supporting snapshot and release types.
*
* @param ord the order of the extension
*/
sealed abstract class Maven(private val ord: Int) extends Ordered[Maven] {
override def compare(that: Maven) = this.ord compare that.ord
}

/**
* Companion object for the [[Maven]] version extension.
*
* Statically importing the contents of this object will put the necessary
* implicits in scope for using extended versions of this type.
*/
object Maven extends ExtensionParser[Maven] {
/**
* The [[ExtensionDef extension definition]] for Maven extensions.
*/
implicit val extensionDef: ExtensionDef[Maven] = ExtensionDef.fromOrdered[Maven](Release)

/**
* The parser for Maven extensions.
*
* @return the parser for Maven extensions
*/
implicit def parser: ExtensionParser[Maven] = this

/**
* A snapshot.
*/
case object Snapshot extends Maven(0) {
override val toString = "SNAPSHOT"
}

/**
* A release.
*/
case object Release extends Maven(1)

@throws[IllegalArgumentException]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ package compat

import com.nthportal.versions.compat.VersionFactoryBase

/**
* A version factory for [[ExtendedVersion]]s.
*
* @inheritdoc
*/
case class VersionFactory[E](extensionDef: ExtensionDef[E], parser: ExtensionParser[E])
extends VersionFactoryBase[Version, E, ExtendedVersion](extensionDef, parser, ExtendedVersion)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ package compat

import com.nthportal.versions.compat.VersionFactoryBase

/**
* A version factory for [[ExtendedVersion]]s.
*
* @inheritdoc
*/
case class VersionFactory[E](extensionDef: ExtensionDef[E], parser: ExtensionParser[E])
extends VersionFactoryBase[Version, E, ExtendedVersion](extensionDef, parser, ExtendedVersion)

0 comments on commit 70f368d

Please sign in to comment.